/** * Sets the document to display and its ViewCSS. */ public void setDocument(Document doc, ViewCSS view) { if (document != null) { if (document != doc) { removeDomMutationListeners(document); addDomMutationListeners(doc); removeCapturingListener(document); addCapturingListener(doc); } } else { addDomMutationListeners(doc); addCapturingListener(doc); } resetHistory(); document = doc; viewCSS = view; TreeNode root = createTree(doc, showWhitespace); ((DefaultTreeModel) tree.getModel()).setRoot(root); if (rightPanel.getComponentCount() != 0) { rightPanel.remove(0); splitPane.revalidate(); splitPane.repaint(); } }
public static Color toSWTColor(Element element, String attributeName) { Document document = element.getOwnerDocument(); ViewCSS viewCSS = (ViewCSS) document.getDocumentElement(); CSSStyleDeclaration computedStyle = viewCSS.getComputedStyle(element, null); SVGPaint svgPaint = (SVGPaint) computedStyle.getPropertyCSSValue(attributeName); if (svgPaint.getPaintType() == SVGPaint.SVG_PAINTTYPE_RGBCOLOR) { RGBColor rgb = svgPaint.getRGBColor(); float red = rgb.getRed().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE); float green = rgb.getGreen().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE); float blue = rgb.getBlue().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE); return SWTResourceManager.getColor((int) red, (int) green, (int) blue); } return null; }
/** * Sets the document to display and its ViewCSS. */ public void setDocument(Document doc, ViewCSS view) { panel.setDocument(doc, view); }
/** * Forces the viewer frame to show the input SVGDocument */ public void setSVGDocument(SVGDocument svgDocument, String svgDocumentURL, String svgDocumentTitle) { this.svgDocument = svgDocument; if (domViewer != null) { if(domViewer.isVisible() && svgDocument != null) { domViewer.setDocument(svgDocument, (ViewCSS)svgDocument.getDocumentElement()); } else { domViewer.dispose(); domViewer = null; } } stopAction.update(false); svgCanvas.setCursor(DEFAULT_CURSOR); String s = svgDocumentURL; locationBar.setText(s); if (debugger != null) { debugger.detach(); debugger.setDocumentURL(s); } if (title == null) { title = getTitle(); } String dt = svgDocumentTitle; if (dt.length() != 0) { setTitle(title + ": " + dt); } else { int i = s.lastIndexOf("/"); if (i == -1) i = s.lastIndexOf("\\"); if (i == -1) { setTitle(title + ": " + s); } else { setTitle(title + ": " + s.substring(i + 1)); } } localHistory.update(s); application.addVisitedURI(s); backAction.update(); forwardAction.update(); transformHistory = new TransformHistory(); previousTransformAction.update(); nextTransformAction.update(); useStylesheetAction.update(); }
/** * <b>DOM</b>: Implements {@link * org.w3c.dom.css.ViewCSS#getComputedStyle(Element,String)}. */ public CSSStyleDeclaration getComputedStyle(Element elt, String pseudoElt) { AbstractView av = ((DocumentView)getOwnerDocument()).getDefaultView(); return ((ViewCSS)av).getComputedStyle(elt, pseudoElt); }
/** * Creates a ViewCSS. */ public ViewCSS createViewCSS(AbstractStylableDocument doc) { return new CSSOMSVGViewCSS(doc.getCSSEngine()); }
protected CSSStyleDeclaration getCssProperties(Element styleElem, String pseudoElt) { return ((ViewCSS) (((DocumentView) doc).getDefaultView())) .getComputedStyle(styleElem, pseudoElt); }
/** * Creates a ViewCSS. */ public abstract ViewCSS createViewCSS(AbstractStylableDocument doc);