📄 drawing.java
字号:
{
initialize();
}
return shapeId;
}
/**
* Accessor for the blip id
*
* @return the blip id
*/
public final int getBlipId()
{
if (!initialized)
{
initialize();
}
return blipId;
}
/**
* Gets the drawing record which was read in
*
* @return the drawing record
*/
public MsoDrawingRecord getMsoDrawingRecord()
{
return msoDrawingRecord;
}
/**
* Creates the main Sp container for the drawing
*
* @return the SP container
*/
public EscherContainer getSpContainer()
{
if (!initialized)
{
initialize();
}
if (origin == Origin.READ)
{
return getReadSpContainer();
}
SpContainer spContainer = new SpContainer();
Sp sp = new Sp(type, shapeId, 2560);
spContainer.add(sp);
Opt opt = new Opt();
opt.addProperty(260, true, false, blipId);
if (type == ShapeType.PICTURE_FRAME)
{
String filePath = imageFile != null ? imageFile.getPath(): "";
opt.addProperty(261, true, true, filePath.length() * 2, filePath);
opt.addProperty(447, false, false, 65536);
opt.addProperty(959, false, false, 524288);
spContainer.add(opt);
}
ClientAnchor clientAnchor = new ClientAnchor(x, y, x + width, y + height);
spContainer.add(clientAnchor);
ClientData clientData = new ClientData();
spContainer.add(clientData);
return spContainer;
}
/**
* Sets the drawing group for this drawing. Called by the drawing group
* when this drawing is added to it
*
* @param dg the drawing group
*/
public void setDrawingGroup(DrawingGroup dg)
{
drawingGroup = dg;
}
/**
* Accessor for the drawing group
*
* @return the drawing group
*/
public DrawingGroup getDrawingGroup()
{
return drawingGroup;
}
/**
* Gets the origin of this drawing
*
* @return where this drawing came from
*/
public Origin getOrigin()
{
return origin;
}
/**
* Accessor for the reference count on this drawing
*
* @return the reference count
*/
public int getReferenceCount()
{
return referenceCount;
}
/**
* Sets the new reference count on the drawing
*
* @param r the new reference count
*/
public void setReferenceCount(int r)
{
referenceCount = r;
}
/**
* Accessor for the column of this drawing
*
* @return the column
*/
public double getX()
{
if (!initialized)
{
initialize();
}
return x;
}
/**
* Sets the column position of this drawing
*
* @param x the column
*/
public void setX(double x)
{
if (origin == Origin.READ)
{
if (!initialized)
{
initialize();
}
origin = Origin.READ_WRITE;
}
this.x = x;
}
/**
* Accessor for the row of this drawing
*
* @return the row
*/
public double getY()
{
if (!initialized)
{
initialize();
}
return y;
}
/**
* Accessor for the row of the drawing
*
* @param y the row
*/
public void setY(double y)
{
if (origin == Origin.READ)
{
if (!initialized)
{
initialize();
}
origin = Origin.READ_WRITE;
}
this.y = y;
}
/**
* Accessor for the width of this drawing
*
* @return the number of columns spanned by this image
*/
public double getWidth()
{
if (!initialized)
{
initialize();
}
return width;
}
/**
* Accessor for the width
*
* @param w the number of columns to span
*/
public void setWidth(double w)
{
if (origin == Origin.READ)
{
if (!initialized)
{
initialize();
}
origin = Origin.READ_WRITE;
}
width = w;
}
/**
* Accessor for the height of this drawing
*
* @return the number of rows spanned by this image
*/
public double getHeight()
{
if (!initialized)
{
initialize();
}
return height;
}
/**
* Accessor for the height of this drawing
*
* @param h the number of rows spanned by this image
*/
public void setHeight(double h)
{
if (origin == Origin.READ)
{
if (!initialized)
{
initialize();
}
origin = Origin.READ_WRITE;
}
height = h;
}
/**
* Gets the SpContainer that was read in
*
* @return the read sp container
*/
private EscherContainer getReadSpContainer()
{
if (!initialized)
{
initialize();
}
return readSpContainer;
}
/**
* Accessor for the image data
*
* @return the image data
*/
public byte[] getImageData()
{
Assert.verify(origin == Origin.READ || origin == Origin.READ_WRITE);
if (!initialized)
{
initialize();
}
return drawingGroup.getImageData(blipId);
}
/**
* Accessor for the image data
*
* @return the image data
*/
public byte[] getImageBytes() throws IOException
{
if (origin == Origin.READ || origin == Origin.READ_WRITE)
{
return getImageData();
}
Assert.verify(origin == Origin.WRITE);
if (imageFile == null)
{
Assert.verify(imageData != null);
return imageData;
}
byte[] data = new byte[(int) imageFile.length()];
FileInputStream fis = new FileInputStream(imageFile);
fis.read(data, 0, data.length);
fis.close();
return data;
}
/**
* Accessor for the type
*
* @return the type
*/
public ShapeType getType()
{
return type;
}
/**
* Writes any other records associated with this drawing group object
*/
public void writeAdditionalRecords(File outputFile) throws IOException
{
if (origin == Origin.READ)
{
outputFile.write(objRecord);
return;
}
// Create the obj record
ObjRecord objRecord = new ObjRecord(objectId,
ObjRecord.PICTURE);
outputFile.write(objRecord);
}
/**
* Writes any records that need to be written after all the drawing group
* objects have been written
* Does nothing here
*/
public void writeTailRecords(File outputFile) throws IOException
{
// does nothing
}
/**
* Interface method
*
* @return the column number at which the image is positioned
*/
public double getColumn()
{
return getX();
}
/**
* Interface method
*
* @return the row number at which the image is positions
*/
public double getRow()
{
return getY();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -