/** * Returns a transform that can translate shape-local coordinates to the * coordinates of its parent shape */ protected AffineTransform getParentTransform() { // TODO: There's probably a better way to do this AffineTransform tr = new AffineTransform(); Double locX = getLocPinX(); Double locY = getLocPinY(); Boolean flipX = getFlipX(); Boolean flipY = getFlipY(); Double angle = getAngle(); tr.translate(-locX, -locY); tr.translate(getPinX(), getPinY()); // rotate about the origin if (angle != null && Math.abs(angle) > 0.001) { tr.rotate(angle, locX, locY); } // flip if necessary if (flipX != null && flipX) { tr.scale(-1, 1); tr.translate(-getWidth(), 0); } if (flipY != null && flipY) { tr.scale(1, -1); tr.translate(0, -getHeight()); } return tr; }
public Double getBeginX() { if (_beginX == null && _masterShape != null) { return _masterShape.getBeginX(); } return _beginX; }
public Double getBeginY() { if (_beginY == null && _masterShape != null) { return _masterShape.getBeginY(); } return _beginY; }
protected void drawText(XDGFShape shape) { XDGFText text = shape.getText(); if (text != null) { if (text.getTextContent().equals("Header")) text.getTextBounds(); Font oldFont = _graphics.getFont(); _graphics.setFont(oldFont.deriveFont(shape.getFontSize() .floatValue())); _graphics.setColor(shape.getFontColor()); text.draw(_graphics); _graphics.setFont(oldFont); } }
Boolean flipX = _parent.getFlipX(); Boolean flipY = _parent.getFlipY(); if (flipY == null || !_parent.getFlipY()) { graphics.translate(bounds.x, bounds.y); graphics.scale(1, -1); if (flipX != null && _parent.getFlipX()) { graphics.scale(-1, 1); graphics.translate(-bounds.width, 0); Double txtAngle = _parent.getTxtAngle(); if (txtAngle != null && Math.abs(txtAngle) > 0.01) { graphics.rotate(txtAngle);
public XDGFShape(XDGFShape parent, ShapeSheetType shapeSheet, XDGFBaseContents parentPage, XDGFDocument document) { super(shapeSheet, document); _parent = parent; _parentPage = parentPage; TextType text = shapeSheet.getText(); if (text != null) { _text = new XDGFText(text, this); } if (shapeSheet.isSetShapes()) { _shapes = new ArrayList<>(); for (ShapeSheetType shape : shapeSheet.getShapes().getShapeArray()) { _shapes.add(new XDGFShape(this, shape, parentPage, document)); } } readProperties(); }
@Override public XDGFCell getCell(String cellName) { XDGFCell _cell = super.getCell(cellName); // if not found, ask the master if (_cell == null && _masterShape != null) { _cell = _masterShape.getCell(cellName); } return _cell; }
public Double getEndY() { if (_endY == null && _masterShape != null) { return _masterShape.getEndY(); } return _endY; }
public Double getEndX() { if (_endX == null && _masterShape != null) { return _masterShape.getEndX(); } return _endX; }
@Override public Color getFontColor() { Color fontColor = super.getFontColor(); if (fontColor != null) { return fontColor; } // get from master if (_masterShape != null) { return _masterShape.getFontColor(); } // get default return _document.getDefaultTextStyle().getFontColor(); }
public Double getAngle() { if (_angle == null && _masterShape != null) { return _masterShape.getAngle(); } return _angle; }
public Boolean getFlipX() { if (_flipX == null && _masterShape != null) { return _masterShape.getFlipX(); } return _flipX; }
public Boolean getFlipY() { if (_flipY == null && _masterShape != null) { return _masterShape.getFlipY(); } return _flipY; }
@Override protected void onDocumentRead() { if (_pageContents.isSetShapes()) { for (ShapeSheetType shapeSheet: _pageContents.getShapes().getShapeArray()) { XDGFShape shape = new XDGFShape(shapeSheet, this, _document); _toplevelShapes.add(shape); addToShapeIndex(shape); } } if (_pageContents.isSetConnects()) { for (ConnectType connect: _pageContents.getConnects().getConnectArray()) { XDGFShape from = _shapes.get(connect.getFromSheet()); XDGFShape to = _shapes.get(connect.getToSheet()); if (from == null) throw new POIXMLException(this + "; Connect; Invalid from id: " + connect.getFromSheet()); if (to == null) throw new POIXMLException(this + "; Connect; Invalid to id: " + connect.getToSheet()); _connections.add(new XDGFConnection(connect, from, to)); } } }
protected void drawText(XDGFShape shape) { XDGFText text = shape.getText(); if (text != null) { if (text.getTextContent().equals("Header")) text.getTextBounds(); Font oldFont = _graphics.getFont(); _graphics.setFont(oldFont.deriveFont(shape.getFontSize() .floatValue())); _graphics.setColor(shape.getFontColor()); text.draw(_graphics); _graphics.setFont(oldFont); } }
Boolean flipX = _parent.getFlipX(); Boolean flipY = _parent.getFlipY(); if (flipY == null || !_parent.getFlipY()) { graphics.translate(bounds.x, bounds.y); graphics.scale(1, -1); if (flipX != null && _parent.getFlipX()) { graphics.scale(-1, 1); graphics.translate(-bounds.width, 0); Double txtAngle = _parent.getTxtAngle(); if (txtAngle != null && Math.abs(txtAngle) > 0.01) { graphics.rotate(txtAngle);
public XDGFShape(XDGFShape parent, ShapeSheetType shapeSheet, XDGFBaseContents parentPage, XDGFDocument document) { super(shapeSheet, document); _parent = parent; _parentPage = parentPage; TextType text = shapeSheet.getText(); if (text != null) { _text = new XDGFText(text, this); } if (shapeSheet.isSetShapes()) { _shapes = new ArrayList<>(); for (ShapeSheetType shape : shapeSheet.getShapes().getShapeArray()) { _shapes.add(new XDGFShape(this, shape, parentPage, document)); } } readProperties(); }
public XDGFCell getFromCell() { return _from.getCell(_connect.getFromCell()); }
public Double getEndY() { if (_endY == null && _masterShape != null) { return _masterShape.getEndY(); } return _endY; }
public Double getEndX() { if (_endX == null && _masterShape != null) { return _masterShape.getEndX(); } return _endX; }