private static void actionShowHUD(AbstractPlugin plugin) { if (!(plugin instanceof HudInterface)) return; HudContainer hudContainer = plugin.getHudContainer(); if (hudContainer == null) { hudContainer = ((HudInterface) plugin).createHudComponent(); if (hudContainer == null) return; hudContainer.setName( "hudEditor::" + plugin.getPaletteModelImpl().getName() + "::" + plugin.getName()); hudContainer.setDisplayName( plugin.getPaletteModelImpl().getDisplayName() + "::" + plugin.getName()); hudContainer.setToolTipText( "hudEditor::" + plugin.getPaletteModelImpl().getName() + "::" + plugin.getName()); plugin.setHudContainer(hudContainer); } if (!hudContainer.isOpened()) { hudContainer.open(); } }
public static void serialize(PaletteScene scene, Element rootElement) { Element pluginsElement = new Element("plugins"); Element thisPluginElement; Point loc; AbstractPlugin plugin; for (PluginNode node : scene.getNodes()) { Widget widget = scene.findWidget(node); loc = widget.getPreferredLocation(); plugin = node.getPlugin(); thisPluginElement = new Element("plugin"); thisPluginElement.setAttribute(ATT_PLUGIN_ID, plugin.getPluginKey().getUniqueID()); thisPluginElement.setAttribute(ATT_PLUGIN_NAME, node.getName()); thisPluginElement.setAttribute(ATT_PLUGIN_X, Integer.toString(loc.x)); thisPluginElement.setAttribute(ATT_PLUGIN_Y, Integer.toString(loc.y)); thisPluginElement.setAttribute( ATT_PLUGIN_HIDDEN, String.valueOf(plugin.isParameterPanelHidden())); boolean isHudOpen = plugin.getHudContainer() != null && plugin.getHudContainer().isOpened(); thisPluginElement.setAttribute(ATT_HUD_VISIBLE, String.valueOf(isHudOpen)); if (plugin instanceof IParameterPanel) { Element parameterPanelElement = ((IParameterPanel) plugin).createWorkspaceParameters(); if (parameterPanelElement != null) { thisPluginElement.addContent(new Element("parameters").addContent(parameterPanelElement)); } } pluginsElement.addContent(thisPluginElement); } rootElement.addContent(pluginsElement); Element connectionsElement = new Element("connections"); Element thisConnectionElement; for (ConnectorEdge edge : scene.getEdges()) { thisConnectionElement = new Element("connection"); thisConnectionElement.setAttribute(ATT_EDGE_ID, edge.getName()); PluginNode sourceNode = scene.getEdgeSource(edge); if (sourceNode != null) { thisConnectionElement.setAttribute(ATT_EDGE_SOURCE, sourceNode.getName()); } PluginNode targetNode = scene.getEdgeTarget(edge); if (targetNode != null) { thisConnectionElement.setAttribute(ATT_EDGE_TARGET, targetNode.getName()); } ConnectionWidget cw = (ConnectionWidget) scene.findWidget(edge); thisConnectionElement.setAttribute( ATT_EDGE_ROUTER, cw.getRouter().getClass().getSimpleName()); List<Point> pts = cw.getControlPoints(); if (pts != null && !pts.isEmpty()) { Element vertsElement = new Element("verts"); Element thisVertexElement; for (Point pt : cw.getControlPoints()) { thisVertexElement = new Element("vert"); thisVertexElement.setAttribute(ATT_VERT_X, Integer.toString(pt.x)); thisVertexElement.setAttribute(ATT_VERT_Y, Integer.toString(pt.y)); vertsElement.addContent(thisVertexElement); } thisConnectionElement.addContent(vertsElement); } connectionsElement.addContent(thisConnectionElement); } rootElement.addContent(connectionsElement); // Save I/O connections Element ioConnectionsElement = new Element("ioConnections"); for (String ioc : scene.getDefaultPaletteModel().getConnections()) { ioConnectionsElement.addContent(new Element("io").setAttribute("name", ioc)); } rootElement.addContent(ioConnectionsElement); Element annotationsElement = new Element("annotations"); Element thisAnnotation; AnnotationWidget aw; Font font; for (Widget w : scene.getChildren()) { if (!(w instanceof AnnotationWidget)) continue; aw = (AnnotationWidget) w; thisAnnotation = new Element("entry"); thisAnnotation.setAttribute("text", aw.getLabel()); font = aw.getFont(); thisAnnotation.setAttribute("font", String.valueOf(font.getName())); thisAnnotation.setAttribute("fontSize", String.valueOf(font.getSize())); thisAnnotation.setAttribute("fontStyle", String.valueOf(font.getStyle())); loc = aw.getPreferredLocation(); thisAnnotation.setAttribute("xLoc", String.valueOf(loc.x)); thisAnnotation.setAttribute("yLoc", String.valueOf(loc.y)); thisAnnotation.setAttribute( "fore", "#" + Integer.toHexString(aw.getForeground().getRGB()).substring(1)); thisAnnotation.setAttribute( "back", "#" + Integer.toHexString(((Color) aw.getBackground()).getRGB()).substring(1)); thisAnnotation.setAttribute("orient", aw.getOrientation().name()); annotationsElement.addContent(thisAnnotation); } rootElement.addContent(annotationsElement); }