private synchronized void setExportProperties(PreviewModel m) { PreviewProperties props = m.getProperties(); props.putValue(PreviewProperty.VISIBILITY_RATIO, 1.0F); props.putValue("width", width); props.putValue("height", height); oldColor = props.getColorValue(PreviewProperty.BACKGROUND_COLOR); if (transparentBackground) { props.putValue( PreviewProperty.BACKGROUND_COLOR, null); //Transparent } props.putValue(PreviewProperty.MARGIN, new Float(margin)); }
@Override public void setMoving(boolean moving) { previewModel.getProperties().putValue(PreviewProperty.MOVING, moving); }
@Override public void itemStateChanged(ItemEvent e) { JComboBox comboBox = (JComboBox) e.getSource(); if (!comboBox.getSelectedItem().equals(NO_SELECTION)) { previewModel.getProperties().putValue(NodesZOrdering.SORT_COLUMN, comboBox.getSelectedItem()); } else { previewModel.getProperties().putValue(NodesZOrdering.SORT_COLUMN, null); } } });
@Override public void propertyChange(PropertyChangeEvent evt) { PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class); previewController.getModel().getProperties().putValue(PreviewProperty.BACKGROUND_COLOR, (Color) evt.getNewValue()); PreviewUIController previewUIController = Lookup.getDefault().lookup(PreviewUIController.class); previewUIController.refreshPreview(); } });
@Override public boolean execute() { PreviewController controller = Lookup.getDefault().lookup(PreviewController.class); controller.getModel(workspace).getProperties().putValue(PreviewProperty.VISIBILITY_RATIO, 1.0); controller.refreshPreview(workspace); PreviewProperties props = controller.getModel(workspace).getProperties(); props.putValue("width", width); props.putValue("height", height); target = (G2DTarget) controller.getRenderTarget(RenderTarget.G2D_TARGET, workspace); try { target.refresh(); Graphics2D pg2 = (Graphics2D) target.getGraphics(); BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); pg2.drawImage(img, null, 0, 0); ImageIO.write(img, "jpg", stream); stream.close(); } catch (Exception e) { throw new RuntimeException(e); } return true; }
public void initTarget(PreviewUIModel previewUIModel) { // inits the preview applet if (previewUIModel != null && target == null) { PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class); PreviewModel previewModel = previewUIModel.getPreviewModel(); Color background = previewModel.getProperties().getColorValue(PreviewProperty.BACKGROUND_COLOR); if (background != null) { setBackgroundColor(background); } Dimension dimensions = getSketchDimensions(); previewModel.getProperties().putValue("width", (int) dimensions.getWidth()); previewModel.getProperties().putValue("height", (int) dimensions.getHeight()); target = (G2DTarget) previewController.getRenderTarget(RenderTarget.G2D_TARGET); if (target != null) { sketch = new PreviewSketch(target); sketchPanel.add(sketch, BorderLayout.CENTER); } } else if (previewUIModel == null) { sketchPanel.remove(sketch); target = null; } }
previewModel.getProperties().putValue(PreviewProperty.SHOW_NODE_LABELS, Boolean.TRUE); previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_COLOR, new DependantOriginalColor(Color.WHITE)); previewModel.getProperties().putValue(PreviewProperty.EDGE_CURVED, Boolean.FALSE); previewModel.getProperties().putValue(PreviewProperty.EDGE_OPACITY, 50); previewModel.getProperties().putValue(PreviewProperty.BACKGROUND_COLOR, Color.BLACK);
Object value = Serialization.readValueFromText(reader.getText(), simpleValueClass); if (value != null) { props.putValue(propName, value);
controller.getModel(workspace).getProperties().putValue(PreviewProperty.VISIBILITY_RATIO, 1.0); controller.refreshPreview(workspace); PreviewProperties props = controller.getModel(workspace).getProperties(); cb.saveState(); props.putValue(PDFTarget.LANDSCAPE, landscape); props.putValue(PDFTarget.PAGESIZE, size); props.putValue(PDFTarget.MARGIN_TOP, new Float((float) marginTop)); props.putValue(PDFTarget.MARGIN_LEFT, new Float((float) marginLeft)); props.putValue(PDFTarget.MARGIN_BOTTOM, new Float((float) marginBottom)); props.putValue(PDFTarget.MARGIN_RIGHT, new Float((float) marginRight)); props.putValue(PDFTarget.PDF_CONTENT_BYTE, cb); target = (PDFTarget) controller.getRenderTarget(RenderTarget.PDF_TARGET, workspace); if (target instanceof LongTask) { props.putValue(PDFTarget.PDF_CONTENT_BYTE, null); props.putValue(PDFTarget.PAGESIZE, null);
@Override public void duplicate(Workspace source, Workspace destination) { PreviewController previewController=Lookup.getDefault().lookup(PreviewController.class); PreviewModel sourceModel=previewController.getModel(source); PreviewModel destModel=previewController.getModel(destination); destModel.setManagedRenderers(sourceModel.getManagedRenderers()); for(PreviewProperty property:sourceModel.getProperties().getProperties()){ destModel.getProperties().putValue(property.getName(), property.getValue()); } for(Entry<String,Object> property:sourceModel.getProperties().getSimpleValues()){ destModel.getProperties().putValue(property.getKey(), property.getValue()); } } }
private synchronized void discardExportProperties(PreviewModel m) { PreviewProperties props = m.getProperties(); props.removeSimpleValue("width"); props.removeSimpleValue("height"); props.removeSimpleValue(PreviewProperty.MARGIN); props.putValue(PreviewProperty.BACKGROUND_COLOR, oldColor); } }
@Override public void mouseClicked(PreviewMouseEvent event, PreviewProperties properties, Workspace workspace) { for (Node node : Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace).getGraph().getNodes()) { if (clickingInNode(node, event)) { properties.putValue("display-label.node.id", node.getId()); System.err.println("Node " + node.getLabel() + " clicked!");//System.out is ignored in Netbeans platform applications!! JOptionPane.showMessageDialog(null, "Node " + node.getLabel() + " clicked!"); event.setConsumed(true);//So the renderer is executed and the graph repainted return; } } properties.removeSimpleValue("display-label.node.id"); event.setConsumed(true);//So the renderer is executed and the graph repainted }
@Override public boolean execute() { PreviewController controller = Lookup.getDefault().lookup(PreviewController.class); controller.getModel(workspace).getProperties().putValue(PreviewProperty.VISIBILITY_RATIO, 1.0); controller.refreshPreview(workspace); props.putValue(SVGTarget.SCALE_STROKES, scaleStrokes); props.putValue(PreviewProperty.MARGIN, new Float((float) margin)); target = (SVGTarget) controller.getRenderTarget(RenderTarget.SVG_TARGET, workspace); if (target instanceof LongTask) {
@Override public void run() { model.setRefreshing(true); fireEvent(REFRESHING, true); previewController.getModel().getProperties().putValue(PreviewProperty.VISIBILITY_RATIO, model.getVisibilityRatio()); previewController.refreshPreview(); fireEvent(REFRESHED, model); model.setRefreshing(false); fireEvent(REFRESHING, false); fireEvent(GRAPH_CHANGED, false); } }, "Refresh Preview");
private synchronized void initProperties() { if (properties == null) { properties = new PreviewProperties(); //Properties from renderers for (Renderer renderer : getManagedEnabledRenderers()) { PreviewProperty[] props = renderer.getProperties(); for (PreviewProperty p : props) { properties.addProperty(p); } } //Default preset properties.applyPreset(new DefaultPreset()); //Defaut values properties.putValue(PreviewProperty.VISIBILITY_RATIO, 1f); } }
model.getProperties().putValue(PreviewProperty.SHOW_NODE_LABELS, Boolean.TRUE); model.getProperties().putValue(PreviewProperty.EDGE_COLOR, new EdgeColor(Color.GRAY)); model.getProperties().putValue(PreviewProperty.EDGE_THICKNESS, new Float(0.1f)); model.getProperties().putValue(PreviewProperty.NODE_LABEL_FONT, model.getProperties().getFontValue(PreviewProperty.NODE_LABEL_FONT).deriveFont(8));
(Double) edge.getData(EdgeItem.WEIGHT)); properties.putValue(EDGE_MIN_WEIGHT, minWeight); properties.putValue(EDGE_MAX_WEIGHT, maxWeight); properties.putValue(BEZIER_CURVENESS, defaultBezierCurviness); properties.putValue(PreviewProperty.EDGE_RESCALE_WEIGHT_MIN, defaultRescaleWeightMin); properties.putValue(PreviewProperty.EDGE_RESCALE_WEIGHT_MAX, defaultRescaleWeightMax);
previewModel.getProperties().putValue(PreviewProperty.DIRECTED, graphModel.isDirected() || graphModel.isMixed());
/** * 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); } } }