@Override public void insertGraphNode(GraphNode graphNode) throws GraphRenderingException { StringBuilder styleSB = new StringBuilder(); if (graphNode.getShape() != null) { String mxShape = getMxShape(graphNode.getShape()); styleSB.append(mxConstants.STYLE_SHAPE).append("=").append(mxShape).append(";"); } GraphNode.Alignment textAlignment = graphNode.getTextAlignment(); if (textAlignment != null) { styleSB.append(mxConstants.STYLE_ALIGN).append("=").append(getMxAlignment(textAlignment)).append(";"); } Color color = graphNode.getFillColor(); if (color != null) { String hexColor = "#" + Integer.toHexString(color.getRGB()).substring(2); styleSB.append(mxConstants.STYLE_FILLCOLOR).append("=").append(hexColor).append(";"); } String label = graphNode.getLabel(); mxRectangle rectangle = mxUtils.getSizeForHtml(label, new HashMap<>(), 1, 0); double width = rectangle.getWidth() + 35; double height = rectangle.getHeight() + 25; Object node = getGraph().insertVertex(getGraph().getDefaultParent(), null, label, 0, 0, width, height); getGraph().getModel().setStyle(node, styleSB.toString()); getGraphNodeObjectMap().put(graphNode, node); }
@Override public void insertGraphEdge(GraphEdge graphEdge) throws GraphRenderingException { Object nodeA = getGraphNodeObjectMap().get(graphEdge.getGraphNodeA()); if (nodeA == null) { throw new GraphRenderingException("First node from edge has not been inserted yet."); } Object nodeB = getGraphNodeObjectMap().get(graphEdge.getGraphNodeB()); if (nodeB == null) { throw new GraphRenderingException("Second node from edge has not been inserted yet."); } StringBuilder styleSB = new StringBuilder(); if (graphEdge.getColor() != null) { styleSB.append(mxConstants.STYLE_STROKECOLOR).append("=").append(graphEdge.getColor()).append(";"); } if (GraphEdge.Style.DASHED.equals(graphEdge.getStyle())) { styleSB.append(mxConstants.STYLE_DASHED).append("=true;"); } styleSB.append(mxConstants.STYLE_ROUNDED).append("=true;"); styleSB.append(mxConstants.STYLE_EDGE).append("=").append(mxConstants.EDGESTYLE_ENTITY_RELATION); String label = graphEdge.getLabel(); Object edge = getGraph().insertEdge(getGraph().getDefaultParent(), null, label, nodeA, nodeB); getGraph().getModel().setStyle(edge, styleSB.toString()); }
model.setStyle(cells[i], style);
model.setStyle(cells[i], style);
graphx.getModel().setStyle(cell, style);
graphx.getModel().setStyle(cell, style);
/** * Insert a spot in the {@link TrackSchemeFrame}, by creating a * {@link mxCell} in the graph model of this frame and position it according * to its feature. */ private mxICell insertSpotInGraph( final Spot spot, final int targetColumn ) { mxICell cellAdded = graph.getCellFor( spot ); if ( cellAdded != null ) { // cell for spot already exist, do nothing and return original spot return cellAdded; } // Instantiate JGraphX cell cellAdded = graph.addJGraphTVertex( spot ); // Position it final int row = spot.getFeature( Spot.FRAME ).intValue(); final double x = ( targetColumn - 1 ) * X_COLUMN_SIZE - DEFAULT_CELL_WIDTH / 2; final double y = ( 0.5 + row ) * Y_COLUMN_SIZE - DEFAULT_CELL_HEIGHT / 2; final mxGeometry geometry = new mxGeometry( x, y, DEFAULT_CELL_WIDTH, DEFAULT_CELL_HEIGHT ); cellAdded.setGeometry( geometry ); // Set its style final double radiusFactor = ( Double ) displaySettings.get( KEY_SPOT_RADIUS_RATIO ); if ( null != spotImageUpdater && doThumbnailCapture ) { final String imageStr = spotImageUpdater.getImageString( spot, radiusFactor ); graph.getModel().setStyle( cellAdded, mxConstants.STYLE_IMAGE + "=" + "data:image/base64," + imageStr ); } return cellAdded; }
/** * Insert a spot in the {@link TrackSchemeFrame}, by creating a * {@link mxCell} in the graph model of this frame and position it according * to its feature. */ private mxICell insertSpotInGraph( final Spot spot, final int targetColumn ) { mxICell cellAdded = graph.getCellFor( spot ); if ( cellAdded != null ) { // cell for spot already exist, do nothing and return original spot return cellAdded; } // Instantiate JGraphX cell cellAdded = graph.addJGraphTVertex( spot ); // Position it final int row = spot.getFeature( Spot.FRAME ).intValue(); final double x = ( targetColumn - 1 ) * X_COLUMN_SIZE - DEFAULT_CELL_WIDTH / 2; final double y = ( 0.5 + row ) * Y_COLUMN_SIZE - DEFAULT_CELL_HEIGHT / 2; final mxGeometry geometry = new mxGeometry( x, y, DEFAULT_CELL_WIDTH, DEFAULT_CELL_HEIGHT ); cellAdded.setGeometry( geometry ); // Set its style final double radiusFactor = ( Double ) displaySettings.get( KEY_SPOT_RADIUS_RATIO ); if ( null != spotImageUpdater && doThumbnailCapture ) { final String imageStr = spotImageUpdater.getImageString( spot, radiusFactor ); graph.getModel().setStyle( cellAdded, mxConstants.STYLE_IMAGE + "=" + "data:image/base64," + imageStr ); } return cellAdded; }
model.setStyle(cells[i], style);
model.setStyle(cells[i], style);
model.setStyle(cells[i], style);
String style = cell.getStyle(); style = mxStyleUtils.setStyle( style, mxConstants.STYLE_IMAGE, "data:image/base64," + imageStr ); graph.getModel().setStyle( cell, style );
final String imageStr = spotImageUpdater.getImageString( spot, radiusFactor ); style = mxStyleUtils.setStyle( style, mxConstants.STYLE_IMAGE, "data:image/base64," + imageStr ); graph.getModel().setStyle( cell, style );
final String imageStr = spotImageUpdater.getImageString( spot, radiusFactor ); style = mxStyleUtils.setStyle( style, mxConstants.STYLE_IMAGE, "data:image/base64," + imageStr ); graph.getModel().setStyle( cell, style );
private void setVertexStyle(final mxICell vertex, final String colorstr) { String targetStyle = vertex.getStyle(); targetStyle = mxStyleUtils.removeAllStylenames(targetStyle); targetStyle = mxStyleUtils.setStyle(targetStyle , mxConstants.STYLE_STROKECOLOR, colorstr ); // Style specifics int width, height; if (globalStyle.equals(SIMPLE_STYLE_NAME)) { targetStyle = mxStyleUtils.setStyle(targetStyle, mxConstants.STYLE_FILLCOLOR, colorstr); width = DEFAULT_CELL_HEIGHT; height = width; } else { targetStyle = mxStyleUtils.setStyle(targetStyle, mxConstants.STYLE_FILLCOLOR, "white"); width = DEFAULT_CELL_WIDTH; height = DEFAULT_CELL_HEIGHT; } targetStyle = globalStyle + ";" + targetStyle; graphx.getModel().setStyle(vertex, targetStyle); graphx.getModel().getGeometry(vertex).setWidth(width); graphx.getModel().getGeometry(vertex).setHeight(height); }
private void setVertexStyle(final mxICell vertex, final String colorstr) { String targetStyle = vertex.getStyle(); targetStyle = mxStyleUtils.removeAllStylenames(targetStyle); targetStyle = mxStyleUtils.setStyle(targetStyle , mxConstants.STYLE_STROKECOLOR, colorstr ); // Style specifics int width, height; if (globalStyle.equals(SIMPLE_STYLE_NAME)) { targetStyle = mxStyleUtils.setStyle(targetStyle, mxConstants.STYLE_FILLCOLOR, colorstr); width = DEFAULT_CELL_HEIGHT; height = width; } else { targetStyle = mxStyleUtils.setStyle(targetStyle, mxConstants.STYLE_FILLCOLOR, "white"); width = DEFAULT_CELL_WIDTH; height = DEFAULT_CELL_HEIGHT; } targetStyle = globalStyle + ";" + targetStyle; graphx.getModel().setStyle(vertex, targetStyle); graphx.getModel().getGeometry(vertex).setWidth(width); graphx.getModel().getGeometry(vertex).setHeight(height); }