/** * Returns an the property value as a <code>Color</code>. * @param property the property's name * @return the property's value or <code>null</code> if not found * @throws ClassCastException if the property can't be cast to <code>Color</code> */ public Color getColorValue(String property) { return getValue(property, null); }
/** * Returns an the property value as a <code>Font</code>. * @param property the property's name * @return the property's value or <code>null</code> if not found * @throws ClassCastException if the property can't be cast to <code>Font</code> */ public Font getFontValue(String property) { return getValue(property, null); }
/** * Returns the property value as a boolean. * @param property the property's name * @return the property's value or <code>false</code> if not found * @throws ClassCastException if the property can't be cast to <code>Boolean</code> */ public boolean getBooleanValue(String property) { return getValue(property, Boolean.FALSE); }
/** * Returns the property value as an string. If the value is not a <code>String</code> * it calls the <code>toString()</code> method. * @param property the property's name * @return the property's value or <code>""</code> if not found */ public String getStringValue(String property) { return getValue(property, "").toString(); }
@Override public RenderTarget buildRenderTarget(PreviewModel previewModel) { Integer width = previewModel.getProperties().getValue("width"); Integer height = previewModel.getProperties().getValue("height"); if (width != null && height != null) { width = Math.max(1, width); height = Math.max(1, height); return new G2DTargetImpl(previewModel, width, height); } else { return new G2DTargetImpl(previewModel, 1, 1); } }
public void renderSquaresJava2D(Item item, G2DTarget target, PreviewProperties properties) { //Params Float x = item.getData(NodeItem.X); Float y = item.getData(NodeItem.Y); Float size = item.getData(NodeItem.SIZE); Color color = item.getData(NodeItem.COLOR); Color borderColor = ((DependantColor) properties.getValue(PreviewProperty.NODE_BORDER_COLOR)).getColor(color); float borderSize = properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH); int alpha = (int) ((properties.getFloatValue(PreviewProperty.NODE_OPACITY) / 100f) * 255f); if (alpha > 255) { alpha = 255; } //Graphics Graphics2D graphics = target.getGraphics(); if (borderSize > 0) { Stroke stroke = new BasicStroke(borderSize); graphics.setStroke(stroke); graphics.setColor(new Color(borderColor.getRed(), borderColor.getGreen(), borderColor.getBlue(), alpha)); graphics.draw(new Rectangle(x.intValue(), y.intValue(), size.intValue(), size.intValue())); } graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha)); graphics.fill(new Rectangle(x.intValue(), y.intValue(), size.intValue(), size.intValue())); }
final Column sortColumn = previewProperties.getValue(SORT_COLUMN);
public void renderG2D(Item item, G2DTarget target, PreviewProperties properties) { //Params Float x = item.getData(NodeItem.X); Float y = item.getData(NodeItem.Y); Float size = item.getData(NodeItem.SIZE); Color color = item.getData(NodeItem.COLOR); Color borderColor = ((DependantColor) properties.getValue(PreviewProperty.NODE_BORDER_COLOR)).getColor(color); float borderSize = properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH); int alpha = properties.getBooleanValue(PreviewProperty.NODE_PER_NODE_OPACITY) ? color.getAlpha() : (int) ((properties.getFloatValue(PreviewProperty.NODE_OPACITY) / 100f) * 255f); if (alpha < 0) { alpha = 0; } if (alpha > 255) { alpha = 255; } //Graphics Graphics2D graphics = target.getGraphics(); x = x - (size / 2f); y = y - (size / 2f); Ellipse2D.Float ellipse = new Ellipse2D.Float(x, y, size, size); if (borderSize > 0) { graphics.setColor(new Color(borderColor.getRed(), borderColor.getGreen(), borderColor.getBlue(), alpha)); graphics.setStroke(new BasicStroke(borderSize)); graphics.draw(ellipse); } graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha)); graphics.fill(ellipse); }
public static Color getColor( final Item item, final PreviewProperties properties) { final Item sourceItem = item.getData(SOURCE); final Item targetItem = item.getData(TARGET); final EdgeColor edgeColor = (EdgeColor) properties.getValue(PreviewProperty.EDGE_COLOR); final Color color = edgeColor.getColor( (Color) item.getData(EdgeItem.COLOR), (Color) sourceItem.getData(NodeItem.COLOR), (Color) targetItem.getData(NodeItem.COLOR)); return new Color( color.getRed(), color.getGreen(), color.getBlue(), (int) (getAlpha(properties) * 255)); }
DependantOriginalColor propColor = properties.getValue(PreviewProperty.NODE_LABEL_COLOR); color = propColor.getColor(nodeColor, color); String label = item.getData(NodeLabelItem.LABEL); DependantColor outlineDependantColor = properties.getValue(PreviewProperty.NODE_LABEL_OUTLINE_COLOR); Float outlineSize = properties.getFloatValue(PreviewProperty.NODE_LABEL_OUTLINE_SIZE); outlineSize = outlineSize * (fontSize / 32f); Boolean showBox = properties.getValue(PreviewProperty.NODE_LABEL_SHOW_BOX); DependantColor boxDependantColor = properties.getValue(PreviewProperty.NODE_LABEL_BOX_COLOR); Color boxColor = boxDependantColor.getColor(nodeColor); int boxAlpha = (int) ((properties.getFloatValue(PreviewProperty.NODE_LABEL_BOX_OPACITY) / 100f) * 255f);
size /= 2f; Color color = item.getData(NodeItem.COLOR); Color borderColor = ((DependantColor) properties.getValue(PreviewProperty.NODE_BORDER_COLOR)).getColor(color); float borderSize = properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH); float alpha = properties.getBooleanValue(PreviewProperty.NODE_PER_NODE_OPACITY) ?
DependantOriginalColor propColor = properties.getValue(PreviewProperty.EDGE_LABEL_COLOR); color = propColor.getColor(edgeColor, color); String label = item.getData(EdgeLabelItem.LABEL); DependantColor outlineDependantColor = properties.getValue(PreviewProperty.EDGE_LABEL_OUTLINE_COLOR); Float outlineSize = properties.getFloatValue(PreviewProperty.EDGE_LABEL_OUTLINE_SIZE); outlineSize = outlineSize * (font.getSize() / 32f);
@Override public RenderTarget buildRenderTarget(PreviewModel previewModel) { CanvasSize cs = previewModel.getGraphicsCanvasSize(); PreviewProperties properties = previewModel.getProperties(); float marginBottom = properties.getFloatValue(PDFTarget.MARGIN_BOTTOM); float marginLeft = properties.getFloatValue(PDFTarget.MARGIN_LEFT); float marginRight = properties.getFloatValue(PDFTarget.MARGIN_RIGHT); float marginTop = properties.getFloatValue(PDFTarget.MARGIN_TOP); com.itextpdf.text.Rectangle pageSize = properties.getValue(PDFTarget.PAGESIZE); boolean landscape = properties.getBooleanValue(PDFTarget.LANDSCAPE); PdfContentByte cb = properties.getValue(PDFTarget.PDF_CONTENT_BYTE); PDFRenderTargetImpl renderTarget = new PDFRenderTargetImpl( cb, cs, pageSize, marginLeft, marginRight, marginTop, marginBottom, landscape); return renderTarget; }
size /= 2f; Color color = item.getData(NodeItem.COLOR); Color borderColor = ((DependantColor) properties.getValue(PreviewProperty.NODE_BORDER_COLOR)).getColor(color); float borderSize = properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH); float alpha = properties.getBooleanValue(PreviewProperty.NODE_PER_NODE_OPACITY) ?
/** * Removes unnecessary properties from not enabled renderers */ private void reloadProperties() { if(properties == null){ initProperties(); }else{ PreviewProperties newProperties = new PreviewProperties();//Ensure that the properties object doesn't change //Properties from renderers for (Renderer renderer : getManagedEnabledRenderers()) { PreviewProperty[] props = renderer.getProperties(); for (PreviewProperty p : props) { newProperties.addProperty(p); if (properties.hasProperty(p.getName())) { newProperties.putValue(p.getName(), properties.getValue(p.getName()));//Keep old values } } } //Remove old properties (this keeps simple values) for (PreviewProperty p : properties.getProperties()) { properties.removeProperty(p); } //Set new properties for (PreviewProperty property : newProperties.getProperties()) { properties.addProperty(property); } } }
Item edgeItem = previewModel.getItem(Item.EDGE, edge); EdgeColor edgeColor = (EdgeColor) properties.getValue(PreviewProperty.EDGE_COLOR); NodeItem sourceItem = (NodeItem) edgeItem.getData(EdgeRenderer.SOURCE); NodeItem targetItem = (NodeItem) edgeItem.getData(EdgeRenderer.TARGET);