org.apache.commons.collections15.functors.ConstantTransformer Java Examples
The following examples show how to use
org.apache.commons.collections15.functors.ConstantTransformer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DiagramGenerator.java From incubator-batchee with Apache License 2.0 | 6 votes |
private Layout<Node, Edge> newLayout(final Diagram diagram) { final Layout<Node, Edge> diagramLayout; if (layout != null && layout.startsWith("spring")) { diagramLayout = new SpringLayout<Node, Edge>(diagram, new ConstantTransformer(Integer.parseInt(config("spring", "100")))); } else if (layout != null && layout.startsWith("kk")) { Distance<Node> distance = new DijkstraDistance<Node, Edge>(diagram); if (layout.endsWith("unweight")) { distance = new UnweightedShortestPath<Node, Edge>(diagram); } diagramLayout = new KKLayout<Node, Edge>(diagram, distance); } else if (layout != null && layout.equalsIgnoreCase("circle")) { diagramLayout = new CircleLayout<Node, Edge>(diagram); } else if (layout != null && layout.equalsIgnoreCase("fr")) { diagramLayout = new FRLayout<Node, Edge>(diagram); } else { final LevelLayout levelLayout = new LevelLayout(diagram); levelLayout.adjust = adjust; diagramLayout = levelLayout; } return diagramLayout; }
Example #2
Source File: GraphOption.java From JPPF with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public synchronized void createUI() { if (graphHandler == null) { if (debugEnabled) log.debug("creating UI"); graphHandler = new GraphTopologyHandler(this); final SparseMultigraph<AbstractTopologyComponent, Number> graph = graphHandler.getDisplayGraph(); layoutFactory = new LayoutFactory(graph); layout = "Radial"; viewer = new VisualizationViewer<>(layoutFactory.createLayout(layout)); layoutFactory.setViewer(viewer); viewer.setBackground(Color.white); viewer.setPickedVertexState(new MultiPickedState<AbstractTopologyComponent>()); viewer.setPickSupport(new ShapePickSupport<>(viewer)); final VertexLabelAsShapeRenderer<AbstractTopologyComponent, Number> vlasr = new VertexLabelAsShapeRenderer<>(viewer.getRenderContext()); viewer.getRenderer().setVertexLabelRenderer(vlasr); viewer.getRenderContext().setVertexShapeTransformer(vlasr); final JPPFVertexLabelRenderer renderer = new JPPFVertexLabelRenderer(); final Dimension d = renderer.getPreferredSize(); d.width = LayoutFactory.VERTEX_SIZE.width; if (d.height < LayoutFactory.VERTEX_SIZE.height) { d.height = LayoutFactory.VERTEX_SIZE.height; renderer.setPreferredSize(d); } viewer.getRenderContext().setVertexLabelRenderer(renderer); viewer.getRenderer().getVertexLabelRenderer().setPosition(Position.AUTO); viewer.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<>(viewer.getPickedVertexState(), viewer.getBackground(), Color.blue)); viewer.getRenderContext().setVertexDrawPaintTransformer(new ConstantTransformer(null)); viewer.getRenderContext().setEdgeStrokeTransformer(new CustomEdgeStrokeTransformer()); viewer.getRenderContext().setEdgeDrawPaintTransformer(new CustomEdgePaintTransformer()); viewer.getRenderContext().setArrowDrawPaintTransformer(new ConstantTransformer(MASTER_SLAVE_PAINT)); viewer.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve()); //viewer.getRenderContext().setEdgeArrowTransformer(); viewer.setVertexToolTipTransformer(new ToStringLabeller<AbstractTopologyComponent>() { @Override public String transform(final AbstractTopologyComponent v) { return v.isNode() ? computeNodeTooltip((TopologyNode) v) : computeDriverTooltip((TopologyDriver) v); } }); graphComponent = new GraphZoomScrollPane(viewer); graphComponent.getVerticalScrollBar().setPreferredSize(new Dimension(GuiUtils.DEFAULT_SCROLLBAR_THICKNESS, 0)); graphComponent.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GuiUtils.DEFAULT_SCROLLBAR_THICKNESS)); actionHandler = new GraphActionHandler(viewer); try { final EditingModalGraphMouse<AbstractTopologyComponent, Number> graphMouse = new EditingModalGraphMouse<>(viewer.getRenderContext(), null, null); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); final PopupMenuMousePlugin<AbstractTopologyComponent, Number> myPlugin = new PopupMenuMousePlugin<>(actionHandler); graphMouse.remove(graphMouse.getPopupEditingPlugin()); graphMouse.add(myPlugin); viewer.setGraphMouse(graphMouse); } catch(final Exception e) { log.error(e.getMessage(), e); } graphComponent.addComponentListener(new ViewerComponentListener()); StatsHandler.getInstance().getShowIPHandler().addShowIPListener((event) -> graphComponent.repaint()); } }