private static SVGGraphics2D toSvgDocument(BitMatrix matrix, MatrixToImageConfig config) { int width = matrix.getWidth(); int height = matrix.getHeight(); DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation(); String svgNS = "http://www.w3.org/2000/svg"; Document document = domImpl.createDocument(svgNS, "svg", null); SVGGraphics2D svgGraphics = new SVGGraphics2D(document); svgGraphics.setColor(new Color(config.getPixelOffColor())); svgGraphics.fillRect(0,0, width, height); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (matrix.get(x,y)) { svgGraphics.setColor(new Color(config.getPixelOnColor())); svgGraphics.fillRect(x, y, 1, 1); } } } return svgGraphics; }
/** * Fires a DOMSubtreeModified event. */ protected void fireDOMSubtreeModifiedEvent() { AbstractDocument doc = getCurrentDocument(); if (doc.getEventsEnabled()) { super.fireDOMSubtreeModifiedEvent(); if (getOwnerElement() != null) { ((AbstractElement)getOwnerElement()). fireDOMSubtreeModifiedEvent(); } } }
/** * The style sheet. */ public StyleSheet getSheet() { if (sheet == null) { sheet = factory.createStyleSheet(this, getPseudoAttributes()); } return sheet; }
private void updateIdEntry(AbstractAttr a, boolean isId) { if (a.isIdAttr) { if (!isId) { ownerDocument.removeIdEntry(this, a.getValue()); } } else if (isId) { ownerDocument.addIdEntry(this, a.getValue()); } }
/** * Deeply exports this node to the given document. */ protected Node deepExport(Node n, AbstractDocument d) { GenericProcessingInstruction p; p = (GenericProcessingInstruction)super.deepExport(n, d); p.setTarget(getTarget()); return p; }
/** * Deeply copy the fields of the current node into the given node. * @param n a node of the type of this. */ protected Node deepCopyInto(Node n) { GenericProcessingInstruction p; p = (GenericProcessingInstruction)super.deepCopyInto(n); p.setTarget(getTarget()); return p; }
/** * Sets the document type node. */ public void setDoctype(DocumentType dt) { if (dt != null) { appendChild(dt); ((ExtendedNode)dt).setReadonly(true); } }
/** * Creates a new DOMImplementation. */ public ExtensibleDOMImplementation() { for (Object o : getDomExtensions()) { DomExtension de = (DomExtension) o; de.registerTags(this); } }
/** * Deeply exports this node to the given document. */ protected Node deepExport(Node n, AbstractDocument d) { super.deepExport(n, d); AbstractAttr aa = (AbstractAttr)n; aa.nodeName = nodeName; aa.unspecified = false; aa.isIdAttr = d.isId(aa); return n; }
public void initialize() { DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
/** * Fires a DOMSubtreeModified event. */ protected void fireDOMSubtreeModifiedEvent() { AbstractDocument doc = getCurrentDocument(); if (doc.getEventsEnabled()) { super.fireDOMSubtreeModifiedEvent(); if (getOwnerElement() != null) { ((AbstractElement)getOwnerElement()). fireDOMSubtreeModifiedEvent(); } } }
/** * The style sheet. */ public StyleSheet getSheet() { if (sheet == null) { sheet = factory.createStyleSheet(this, getPseudoAttributes()); } return sheet; }
private void updateIdEntry(AbstractAttr a, boolean isId) { if (a.isIdAttr) { if (!isId) { ownerDocument.removeIdEntry(this, a.getValue()); } } else if (isId) { ownerDocument.addIdEntry(this, a.getValue()); } }
/** * Sets the document type node. */ public void setDoctype(DocumentType dt) { if (dt != null) { appendChild(dt); ((ExtendedNode)dt).setReadonly(true); } }
/** * Creates a new DOMImplementation. */ public ExtensibleDOMImplementation() { for (Object o : getDomExtensions()) { DomExtension de = (DomExtension) o; de.registerTags(this); } }
/** * The style sheet. */ public StyleSheet getSheet() { if (sheet == null) { sheet = factory.createStyleSheet(this, getPseudoAttributes()); } return sheet; }