git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@744257 13f79535-47bb-0310-9956-ffa450edef68tags/REL_3_5_BETA6
@@ -57,7 +57,7 @@ public class HSSFComment extends HSSFTextbox implements Comment { | |||
setShapeType(OBJECT_TYPE_COMMENT); | |||
//default color for comments | |||
fillColor = 0x08000050; | |||
_fillColor = 0x08000050; | |||
//by default comments are hidden | |||
_visible = false; |
@@ -35,32 +35,29 @@ import org.apache.poi.ss.usermodel.ClientAnchor; | |||
* | |||
* @author Glen Stampoultzis (glens at apache.org) | |||
*/ | |||
public class HSSFPatriarch | |||
implements HSSFShapeContainer, Drawing | |||
{ | |||
List shapes = new ArrayList(); | |||
HSSFSheet sheet; | |||
int x1 = 0; | |||
int y1 = 0 ; | |||
int x2 = 1023; | |||
int y2 = 255; | |||
public final class HSSFPatriarch implements HSSFShapeContainer, Drawing { | |||
private final List<HSSFShape> _shapes = new ArrayList<HSSFShape>(); | |||
private int _x1 = 0; | |||
private int _y1 = 0 ; | |||
private int _x2 = 1023; | |||
private int _y2 = 255; | |||
/** | |||
* The EscherAggregate we have been bound to. | |||
* (This will handle writing us out into records, | |||
* and building up our shapes from the records) | |||
*/ | |||
private EscherAggregate boundAggregate; | |||
private EscherAggregate _boundAggregate; | |||
final HSSFSheet _sheet; // TODO make private | |||
/** | |||
* Creates the patriarch. | |||
* | |||
* @param sheet the sheet this patriarch is stored in. | |||
*/ | |||
HSSFPatriarch(HSSFSheet sheet, EscherAggregate boundAggregate) | |||
{ | |||
this.boundAggregate = boundAggregate; | |||
this.sheet = sheet; | |||
HSSFPatriarch(HSSFSheet sheet, EscherAggregate boundAggregate){ | |||
_sheet = sheet; | |||
_boundAggregate = boundAggregate; | |||
} | |||
/** | |||
@@ -74,7 +71,7 @@ public class HSSFPatriarch | |||
{ | |||
HSSFShapeGroup group = new HSSFShapeGroup(null, anchor); | |||
group.anchor = anchor; | |||
shapes.add(group); | |||
_shapes.add(group); | |||
return group; | |||
} | |||
@@ -90,7 +87,7 @@ public class HSSFPatriarch | |||
{ | |||
HSSFSimpleShape shape = new HSSFSimpleShape(null, anchor); | |||
shape.anchor = anchor; | |||
shapes.add(shape); | |||
_shapes.add(shape); | |||
return shape; | |||
} | |||
@@ -106,8 +103,8 @@ public class HSSFPatriarch | |||
HSSFPicture shape = new HSSFPicture(null, anchor); | |||
shape.setPictureIndex( pictureIndex ); | |||
shape.anchor = anchor; | |||
shape.patriarch = this; | |||
shapes.add(shape); | |||
shape._patriarch = this; | |||
_shapes.add(shape); | |||
return shape; | |||
} | |||
public HSSFPicture createPicture(ClientAnchor anchor, int pictureIndex) | |||
@@ -126,7 +123,7 @@ public class HSSFPatriarch | |||
{ | |||
HSSFPolygon shape = new HSSFPolygon(null, anchor); | |||
shape.anchor = anchor; | |||
shapes.add(shape); | |||
_shapes.add(shape); | |||
return shape; | |||
} | |||
@@ -141,7 +138,7 @@ public class HSSFPatriarch | |||
{ | |||
HSSFTextbox shape = new HSSFTextbox(null, anchor); | |||
shape.anchor = anchor; | |||
shapes.add(shape); | |||
_shapes.add(shape); | |||
return shape; | |||
} | |||
@@ -156,41 +153,38 @@ public class HSSFPatriarch | |||
{ | |||
HSSFComment shape = new HSSFComment(null, anchor); | |||
shape.anchor = anchor; | |||
shapes.add(shape); | |||
_shapes.add(shape); | |||
return shape; | |||
} | |||
/** | |||
* Returns a list of all shapes contained by the patriarch. | |||
*/ | |||
public List getChildren() | |||
public List<HSSFShape> getChildren() | |||
{ | |||
return shapes; | |||
return _shapes; | |||
} | |||
/** | |||
* Total count of all children and their children's children. | |||
*/ | |||
public int countOfAllChildren() | |||
{ | |||
int count = shapes.size(); | |||
for ( Iterator iterator = shapes.iterator(); iterator.hasNext(); ) | |||
{ | |||
HSSFShape shape = (HSSFShape) iterator.next(); | |||
public int countOfAllChildren() { | |||
int count = _shapes.size(); | |||
for (Iterator<HSSFShape> iterator = _shapes.iterator(); iterator.hasNext();) { | |||
HSSFShape shape = iterator.next(); | |||
count += shape.countOfAllChildren(); | |||
} | |||
return count; | |||
} | |||
/** | |||
* Sets the coordinate space of this group. All children are contrained | |||
* Sets the coordinate space of this group. All children are constrained | |||
* to these coordinates. | |||
*/ | |||
public void setCoordinates( int x1, int y1, int x2, int y2 ) | |||
{ | |||
this.x1 = x1; | |||
this.y1 = y1; | |||
this.x2 = x2; | |||
this.y2 = y2; | |||
public void setCoordinates(int x1, int y1, int x2, int y2){ | |||
_x1 = x1; | |||
_y1 = y1; | |||
_x2 = x2; | |||
_y2 = y2; | |||
} | |||
/** | |||
@@ -205,18 +199,18 @@ public class HSSFPatriarch | |||
// We're looking for a EscherOptRecord | |||
EscherOptRecord optRecord = (EscherOptRecord) | |||
boundAggregate.findFirstWithId(EscherOptRecord.RECORD_ID); | |||
_boundAggregate.findFirstWithId(EscherOptRecord.RECORD_ID); | |||
if(optRecord == null) { | |||
// No opt record, can't have chart | |||
return false; | |||
} | |||
for(Iterator it = optRecord.getEscherProperties().iterator(); it.hasNext();) { | |||
EscherProperty prop = (EscherProperty)it.next(); | |||
for(Iterator<EscherProperty> it = optRecord.getEscherProperties().iterator(); it.hasNext();) { | |||
EscherProperty prop = it.next(); | |||
if(prop.getPropertyNumber() == 896 && prop.isComplex()) { | |||
EscherComplexProperty cp = (EscherComplexProperty)prop; | |||
String str = StringUtil.getFromUnicodeLE(cp.getComplexData()); | |||
//System.err.println(str); | |||
if(str.equals("Chart 1\0")) { | |||
return true; | |||
} | |||
@@ -231,7 +225,7 @@ public class HSSFPatriarch | |||
*/ | |||
public int getX1() | |||
{ | |||
return x1; | |||
return _x1; | |||
} | |||
/** | |||
@@ -239,7 +233,7 @@ public class HSSFPatriarch | |||
*/ | |||
public int getY1() | |||
{ | |||
return y1; | |||
return _y1; | |||
} | |||
/** | |||
@@ -247,7 +241,7 @@ public class HSSFPatriarch | |||
*/ | |||
public int getX2() | |||
{ | |||
return x2; | |||
return _x2; | |||
} | |||
/** | |||
@@ -255,13 +249,13 @@ public class HSSFPatriarch | |||
*/ | |||
public int getY2() | |||
{ | |||
return y2; | |||
return _y2; | |||
} | |||
/** | |||
* Returns the aggregate escher record we're bound to | |||
*/ | |||
protected EscherAggregate _getBoundAggregate() { | |||
return boundAggregate; | |||
return _boundAggregate; | |||
} | |||
} |
@@ -1,19 +1,20 @@ | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||
* contributor license agreements. See the NOTICE file distributed with | |||
* this work for additional information regarding copyright ownership. | |||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||
* (the "License"); you may not use this file except in compliance with | |||
* the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
/* ==================================================================== | |||
Licensed to the Apache Software Foundation (ASF) under one or more | |||
contributor license agreements. See the NOTICE file distributed with | |||
this work for additional information regarding copyright ownership. | |||
The ASF licenses this file to You under the Apache License, Version 2.0 | |||
(the "License"); you may not use this file except in compliance with | |||
the License. You may obtain a copy of the License at | |||
http://www.apache.org/licenses/LICENSE-2.0 | |||
Unless required by applicable law or agreed to in writing, software | |||
distributed under the License is distributed on an "AS IS" BASIS, | |||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
See the License for the specific language governing permissions and | |||
limitations under the License. | |||
==================================================================== */ | |||
package org.apache.poi.hssf.usermodel; | |||
import org.apache.poi.ddf.EscherBSERecord; | |||
@@ -38,9 +39,7 @@ import java.util.Iterator; | |||
* @author Glen Stampoultzis | |||
* @author Yegor Kozlov (yegor at apache.org) | |||
*/ | |||
public class HSSFPicture | |||
extends HSSFSimpleShape implements Picture | |||
{ | |||
public final class HSSFPicture extends HSSFSimpleShape implements Picture { | |||
public static final int PICTURE_TYPE_EMF = HSSFWorkbook.PICTURE_TYPE_EMF; // Windows Enhanced Metafile | |||
public static final int PICTURE_TYPE_WMF = HSSFWorkbook.PICTURE_TYPE_WMF; // Windows Metafile | |||
public static final int PICTURE_TYPE_PICT = HSSFWorkbook.PICTURE_TYPE_PICT; // Macintosh PICT | |||
@@ -62,8 +61,8 @@ public class HSSFPicture | |||
*/ | |||
private static final int PX_ROW = 15; | |||
int pictureIndex; | |||
HSSFPatriarch patriarch; | |||
private int _pictureIndex; | |||
HSSFPatriarch _patriarch; // TODO make private | |||
private static final POILogger log = POILogFactory.getLogger(HSSFPicture.class); | |||
@@ -78,12 +77,12 @@ public class HSSFPicture | |||
public int getPictureIndex() | |||
{ | |||
return pictureIndex; | |||
return _pictureIndex; | |||
} | |||
public void setPictureIndex( int pictureIndex ) | |||
{ | |||
this.pictureIndex = pictureIndex; | |||
this._pictureIndex = pictureIndex; | |||
} | |||
/** | |||
@@ -185,7 +184,7 @@ public class HSSFPicture | |||
private float getColumnWidthInPixels(int column){ | |||
int cw = patriarch.sheet.getColumnWidth(column); | |||
int cw = _patriarch._sheet.getColumnWidth(column); | |||
float px = getPixelWidth(column); | |||
return cw/px; | |||
@@ -193,18 +192,18 @@ public class HSSFPicture | |||
private float getRowHeightInPixels(int i){ | |||
HSSFRow row = patriarch.sheet.getRow(i); | |||
HSSFRow row = _patriarch._sheet.getRow(i); | |||
float height; | |||
if(row != null) height = row.getHeight(); | |||
else height = patriarch.sheet.getDefaultRowHeight(); | |||
else height = _patriarch._sheet.getDefaultRowHeight(); | |||
return height/PX_ROW; | |||
} | |||
private float getPixelWidth(int column){ | |||
int def = patriarch.sheet.getDefaultColumnWidth()*256; | |||
int cw = patriarch.sheet.getColumnWidth(column); | |||
int def = _patriarch._sheet.getDefaultColumnWidth()*256; | |||
int cw = _patriarch._sheet.getColumnWidth(column); | |||
return cw == def ? PX_DEFAULT : PX_MODIFIED; | |||
} | |||
@@ -238,7 +237,7 @@ public class HSSFPicture | |||
* @return image dimension | |||
*/ | |||
public Dimension getImageDimension(){ | |||
EscherBSERecord bse = patriarch.sheet.book.getBSERecord(pictureIndex); | |||
EscherBSERecord bse = _patriarch._sheet._book.getBSERecord(_pictureIndex); | |||
byte[] data = bse.getBlipRecord().getPicturedata(); | |||
int type = bse.getBlipTypeWin32(); | |||
Dimension size = new Dimension(); | |||
@@ -252,8 +251,8 @@ public class HSSFPicture | |||
try { | |||
//read the image using javax.imageio.* | |||
ImageInputStream iis = ImageIO.createImageInputStream( new ByteArrayInputStream(data) ); | |||
Iterator i = ImageIO.getImageReaders( iis ); | |||
ImageReader r = (ImageReader) i.next(); | |||
Iterator<ImageReader> i = ImageIO.getImageReaders( iis ); | |||
ImageReader r = i.next(); | |||
r.setInput( iis ); | |||
BufferedImage img = r.read(0); | |||
@@ -22,8 +22,7 @@ package org.apache.poi.hssf.usermodel; | |||
* | |||
* @author Glen Stampoultzis (glens at apache.org) | |||
*/ | |||
public abstract class HSSFShape | |||
{ | |||
public abstract class HSSFShape { | |||
public static final int LINEWIDTH_ONE_PT = 12700; | |||
public static final int LINEWIDTH_DEFAULT = 9525; | |||
@@ -40,13 +39,14 @@ public abstract class HSSFShape | |||
public static final int LINESTYLE_LONGDASHDOTDOTGEL = 10; // long dash short dash short dash | |||
public static final int LINESTYLE_NONE = -1; | |||
HSSFShape parent; | |||
// TODO - make all these fields private | |||
final HSSFShape parent; | |||
HSSFAnchor anchor; | |||
int lineStyleColor = 0x08000040; | |||
int fillColor = 0x08000009; | |||
int lineWidth = LINEWIDTH_DEFAULT; // 12700 = 1pt | |||
int lineStyle = LINESTYLE_SOLID; | |||
boolean noFill = false; | |||
private int _lineStyleColor = 0x08000040; | |||
int _fillColor = 0x08000009; | |||
private int _lineWidth = LINEWIDTH_DEFAULT; // 12700 = 1pt | |||
private int _lineStyle = LINESTYLE_SOLID; | |||
private boolean _noFill = false; | |||
/** | |||
* Create a new shape with the specified parent and anchor. | |||
@@ -103,25 +103,22 @@ public abstract class HSSFShape | |||
/** | |||
* The color applied to the lines of this shape. | |||
*/ | |||
public int getLineStyleColor() | |||
{ | |||
return lineStyleColor; | |||
public int getLineStyleColor() { | |||
return _lineStyleColor; | |||
} | |||
/** | |||
* The color applied to the lines of this shape. | |||
*/ | |||
public void setLineStyleColor( int lineStyleColor ) | |||
{ | |||
this.lineStyleColor = lineStyleColor; | |||
public void setLineStyleColor(int lineStyleColor) { | |||
_lineStyleColor = lineStyleColor; | |||
} | |||
/** | |||
* The color applied to the lines of this shape. | |||
*/ | |||
public void setLineStyleColor( int red, int green, int blue ) | |||
{ | |||
this.lineStyleColor = ((blue) << 16) | ((green) << 8) | red; | |||
public void setLineStyleColor(int red, int green, int blue) { | |||
this._lineStyleColor = ((blue) << 16) | ((green) << 8) | red; | |||
} | |||
/** | |||
@@ -129,15 +126,14 @@ public abstract class HSSFShape | |||
*/ | |||
public int getFillColor() | |||
{ | |||
return fillColor; | |||
return _fillColor; | |||
} | |||
/** | |||
* The color used to fill this shape. | |||
*/ | |||
public void setFillColor( int fillColor ) | |||
{ | |||
this.fillColor = fillColor; | |||
public void setFillColor(int fillColor) { | |||
_fillColor = fillColor; | |||
} | |||
/** | |||
@@ -145,15 +141,14 @@ public abstract class HSSFShape | |||
*/ | |||
public void setFillColor( int red, int green, int blue ) | |||
{ | |||
this.fillColor = ((blue) << 16) | ((green) << 8) | red; | |||
this._fillColor = ((blue) << 16) | ((green) << 8) | red; | |||
} | |||
/** | |||
* @return returns with width of the line in EMUs. 12700 = 1 pt. | |||
*/ | |||
public int getLineWidth() | |||
{ | |||
return lineWidth; | |||
public int getLineWidth() { | |||
return _lineWidth; | |||
} | |||
/** | |||
@@ -163,17 +158,15 @@ public abstract class HSSFShape | |||
* | |||
* @see HSSFShape#LINEWIDTH_ONE_PT | |||
*/ | |||
public void setLineWidth( int lineWidth ) | |||
{ | |||
this.lineWidth = lineWidth; | |||
public void setLineWidth(int lineWidth) { | |||
_lineWidth = lineWidth; | |||
} | |||
/** | |||
* @return One of the constants in LINESTYLE_* | |||
*/ | |||
public int getLineStyle() | |||
{ | |||
return lineStyle; | |||
public int getLineStyle() { | |||
return _lineStyle; | |||
} | |||
/** | |||
@@ -181,32 +174,28 @@ public abstract class HSSFShape | |||
* | |||
* @param lineStyle One of the constants in LINESTYLE_* | |||
*/ | |||
public void setLineStyle( int lineStyle ) | |||
{ | |||
this.lineStyle = lineStyle; | |||
public void setLineStyle(int lineStyle) { | |||
_lineStyle = lineStyle; | |||
} | |||
/** | |||
* @return true if this shape is not filled with a color. | |||
* @return <code>true</code> if this shape is not filled with a color. | |||
*/ | |||
public boolean isNoFill() | |||
{ | |||
return noFill; | |||
public boolean isNoFill() { | |||
return _noFill; | |||
} | |||
/** | |||
* Sets whether this shape is filled or transparent. | |||
*/ | |||
public void setNoFill( boolean noFill ) | |||
{ | |||
this.noFill = noFill; | |||
public void setNoFill(boolean noFill) { | |||
_noFill = noFill; | |||
} | |||
/** | |||
* Count of all children and their childrens children. | |||
* Count of all children and their children's children. | |||
*/ | |||
public int countOfAllChildren() | |||
{ | |||
public int countOfAllChildren() { | |||
return 1; | |||
} | |||
} |