private boolean showNodes(PreviewProperties properties) { return properties.getFloatValue(PreviewProperty.NODE_OPACITY) > 0; }
private void setEdgeWeight(double weight, final PreviewProperties properties, final Item item) { //Multiply by thickness weight *= properties.getFloatValue(PreviewProperty.EDGE_THICKNESS); item.setData(EdgeItem.WEIGHT, weight); }
@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; }
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())); }
@Override public CanvasSize getCanvasSize( final Item item, final PreviewProperties properties) { final float x = item.getData(NodeItem.X); final float y = item.getData(NodeItem.Y); final float s = (Float) item.getData(NodeItem.SIZE) + properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH); final float r = s / 2F; final int intS = Math.round(s); return new CanvasSize( Math.round(x - r), Math.round(y - r), intS, intS); }
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); }
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) ? color.getAlpha() / 255f: properties.getFloatValue(PreviewProperty.NODE_OPACITY) / 100f; if (alpha > 1) { alpha = 1;
Float outlineSize = properties.getFloatValue(PreviewProperty.EDGE_LABEL_OUTLINE_SIZE); outlineSize = outlineSize * (font.getSize() / 32f); int outlineAlpha = (int) ((properties.getFloatValue(PreviewProperty.EDGE_LABEL_OUTLINE_OPACITY) / 100f) * 255f); if (outlineAlpha < 0) { outlineAlpha = 0;
@Override public void select(Workspace workspace) { graphModel = graphController.getGraphModel(workspace); PreviewModel previewModel = previewController.getModel(workspace); model = workspace.getLookup().lookup(PreviewUIModelImpl.class); if (model == null) { model = new PreviewUIModelImpl(previewModel); workspace.add(model); } Float visibilityRatio = previewModel.getProperties().getFloatValue(PreviewProperty.VISIBILITY_RATIO); ((PreviewUIModelImpl) model).setVisibilityRatio(visibilityRatio); fireEvent(SELECT, model); }
Float outlineSize = properties.getFloatValue(PreviewProperty.NODE_LABEL_OUTLINE_SIZE); outlineSize = outlineSize * (fontSize / 32f); int outlineAlpha = (int) ((properties.getFloatValue(PreviewProperty.NODE_LABEL_OUTLINE_OPACITY) / 100f) * 255f); if (outlineAlpha < 0) { outlineAlpha = 0; 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); if (boxAlpha < 0) { boxAlpha = 0;
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) ? color.getAlpha() / 255f : properties.getFloatValue(PreviewProperty.NODE_OPACITY) / 100f;
double minRescaledWeight = properties.getFloatValue(PreviewProperty.EDGE_RESCALE_WEIGHT_MIN); double maxRescaledWeight = properties.getFloatValue(PreviewProperty.EDGE_RESCALE_WEIGHT_MAX); if (!(Boolean) item.getData(EdgeItem.SELF_LOOP)) { final float edgeRadius = properties.getFloatValue(PreviewProperty.EDGE_RADIUS); final Double weight = item.getData(EdgeItem.WEIGHT); float arrowSize = properties.getFloatValue( PreviewProperty.ARROW_SIZE); if (arrowSize < 0F) { + properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH) / 2f //We have to divide by 2 because the border stroke is not only an outline but also draws the other half of the curve inside the node + arrowRadiusSize); item.setData(TARGET_RADIUS, targetRadius); final float sourceRadius = -(edgeRadius + (Float) sourceItem.getData(NodeItem.SIZE) / 2f + properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH) / 2f); item.setData(SOURCE_RADIUS, sourceRadius);
pc.getCurrentWorkspace().add(model); Float visibilityRatio = previewController.getModel().getProperties().getFloatValue(PreviewProperty.VISIBILITY_RATIO); if (visibilityRatio != null) { ((PreviewUIModelImpl) model).setVisibilityRatio(visibilityRatio);
private CanvasSize getSheetCanvasSize(PreviewModel m) { CanvasSize cs = m.getGraphicsCanvasSize(); float marginPercentage = m.getProperties() .getFloatValue(PreviewProperty.MARGIN); float marginWidth = cs.getWidth() * marginPercentage / 100F; float marginHeight = cs.getHeight() * marginPercentage / 100F; return new CanvasSize( cs.getX() - marginWidth, cs.getY() - marginHeight, cs.getWidth() + 2F * marginWidth, cs.getHeight() + 2F * marginHeight); }
if (previewModel.getProperties().getFloatValue(PreviewProperty.VISIBILITY_RATIO) < 1f) { float visibilityRatio = previewModel.getProperties().getFloatValue(PreviewProperty.VISIBILITY_RATIO); GraphView reducedView = graphModel.copyView(graph.getView()); graph = graphModel.getGraph(reducedView); if (previewModel.getProperties().getFloatValue(PreviewProperty.VISIBILITY_RATIO) < 1f) { graphModel.destroyView(graph.getView());
final float size = properties.getFloatValue(PreviewProperty.ARROW_SIZE) float radius = -(properties.getFloatValue(PreviewProperty.EDGE_RADIUS) + (Float) targetItem.getData(NodeItem.SIZE) / 2f + Math.max(0, properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH)) / 2f //We have to divide by 2 because the border stroke is not only an outline but also draws the other half of the curve inside the node );
public Helper( final Item item, final PreviewProperties properties) { sourceItem = item.getData(SOURCE); targetItem = item.getData(TARGET); x1 = sourceItem.getData(NodeItem.X); x2 = targetItem.getData(NodeItem.X); y1 = sourceItem.getData(NodeItem.Y); y2 = targetItem.getData(NodeItem.Y); final Vector direction = new Vector(x2, y2); direction.sub(new Vector(x1, y1)); final float length = direction.mag(); direction.normalize(); final float factor = properties.getFloatValue(BEZIER_CURVENESS) * length; final Vector n = new Vector(direction.y, -direction.x); n.mult(factor); v1 = computeCtrlPoint(x1, y1, direction, factor, n); v2 = computeCtrlPoint(x2, y2, direction, -factor, n); }
direction.normalize(); float factor = properties.getFloatValue(EdgeRenderer.BEZIER_CURVENESS) * length;