@Override public boolean needsItemBuilder(ItemBuilder itemBuilder, PreviewProperties properties) { return itemBuilder instanceof NodeBuilder && properties.getBooleanValue(ENABLE_NODE_GLOW); } }
private boolean showArrows(PreviewProperties properties) { return properties.getBooleanValue(PreviewProperty.SHOW_EDGES) && properties.getBooleanValue(PreviewProperty.DIRECTED) && !properties.getBooleanValue(PreviewProperty.EDGE_CURVED) && !properties.getBooleanValue(PreviewProperty.MOVING); }
private boolean showNodeLabels(PreviewProperties properties) { return properties.getBooleanValue(PreviewProperty.SHOW_NODE_LABELS) && !properties.getBooleanValue(PreviewProperty.MOVING); }
private boolean showEdgeLabels(PreviewProperties properties) { return properties.getBooleanValue(PreviewProperty.SHOW_EDGE_LABELS) && !properties.getBooleanValue(PreviewProperty.MOVING); }
private boolean showEdges(PreviewProperties properties) { return properties.getBooleanValue(PreviewProperty.SHOW_EDGES) && !properties.getBooleanValue(PreviewProperty.MOVING); }
@Override public boolean isRendererForitem(Item item, PreviewProperties properties) { return item instanceof NodeItem && properties.getBooleanValue(ENABLE_NODE_GLOW); }
@Override public CanvasSize getCanvasSize( final Item item, final PreviewProperties properties) { final Helper h = new Helper(item, properties); final float minX = Math.min(Math.min(h.p1.x, h.p2.x), h.p3.x); final float minY = Math.min(Math.min(h.p1.y, h.p2.y), h.p3.y); final float maxX = Math.max(Math.max(h.p1.x, h.p2.x), h.p3.x); final float maxY = Math.max(Math.max(h.p1.y, h.p2.y), h.p3.y); return properties.getBooleanValue(PreviewProperty.EDGE_CURVED) ? new CanvasSize() : new CanvasSize(minX, minY, maxX - minX, maxY - minY); }
@Override public RenderTarget buildRenderTarget(PreviewModel previewModel) { CanvasSize cs = previewModel.getGraphicsCanvasSize(); boolean scaleStrokes = previewModel.getProperties() .getBooleanValue(SVGTarget.SCALE_STROKES); SVGRenderTargetImpl renderTarget = new SVGRenderTargetImpl(cs, scaleStrokes); return renderTarget; }
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); }
@Override public void render( Item item, RenderTarget target, PreviewProperties properties) { if (isSelfLoopEdge(item)) { SELF_LOOP_RENDERER.render(item, target, properties); } else if (properties.getBooleanValue(PreviewProperty.EDGE_CURVED)) { CURVED_RENDERER.render(item, target, properties); } else { STRAIGHT_RENDERER.render(item, target, properties); } }
@Override public CanvasSize getCanvasSize(Item item, PreviewProperties properties) { if (isSelfLoopEdge(item)) { return SELF_LOOP_RENDERER.getCanvasSize(item, properties); } else if (properties.getBooleanValue(PreviewProperty.EDGE_CURVED)) { return CURVED_RENDERER.getCanvasSize(item, properties); } else { return STRAIGHT_RENDERER.getCanvasSize(item, properties); } }
@Override public void render(Item item, RenderTarget target, PreviewProperties properties) { if (properties.getBooleanValue("SquareNodes.property.enable")) { if (target instanceof G2DTarget) { renderSquaresJava2D(item, (G2DTarget) target, properties); } else if (target instanceof SVGTarget) { renderSquaresSVG(item, (SVGTarget) target, properties); } else if (target instanceof PDFTarget) { renderSquaresPDF(item, (PDFTarget) target, properties); } } else { super.render(item, target, properties); } }
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) ? color.getAlpha() / 255f: properties.getFloatValue(PreviewProperty.NODE_OPACITY) / 100f;
@Override public void preProcess(PreviewModel previewModel) { PreviewProperties properties = previewModel.getProperties(); //Check if the boolean property is set if (properties.getBooleanValue(MUTUALEGDE_HIGHLIGHT)) { Color color = properties.getColorValue(MUTUALEGDE_HIGHLIGHT_COLOR); // Retrieve all edge items in the model // As this renderer is called after the EdgeRenderer (which has a position=100, // and this renderer has no specific position) we know these edge // items are well defined and already posses a color Item[] edgeItems = previewModel.getItems(Item.EDGE); for (Item item : edgeItems) { EdgeItem edgeItem = (EdgeItem) item; Boolean mutual = edgeItem.getData(EdgeItem.MUTUAL); if (mutual) { //If mutual edge, change the color edgeItem.setData(EdgeItem.COLOR, color); } } } }
@Override public void preProcess(PreviewModel previewModel) { PreviewProperties properties = previewModel.getProperties(); if (properties.getBooleanValue(PreviewProperty.NODE_LABEL_SHORTEN)) { fontSize = item.getData(NodeLabelItem.SIZE); if (properties.getBooleanValue(PreviewProperty.NODE_LABEL_PROPORTIONAL_SIZE)) { fontSize *= nodeSize / 10f;
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) ? color.getAlpha() / 255f : properties.getFloatValue(PreviewProperty.NODE_OPACITY) / 100f;
@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; }
final boolean rescaleWeight = properties.getBooleanValue( PreviewProperty.EDGE_RESCALE_WEIGHT);
@Override public void preProcess(PreviewModel previewModel) { PreviewProperties properties = previewModel.getProperties(); if (properties.getBooleanValue(PreviewProperty.EDGE_LABEL_SHORTEN)) { item.setData(LABEL_Y, middle.y); } else if (properties.getBooleanValue(PreviewProperty.EDGE_CURVED)) {