rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
return new gnu.xml.aelfred2.JAXPFactory();
return new gnu.xml.stream.SAXParserFactory();
public static SAXParserFactory newInstance() throws FactoryConfigurationError { ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader == null) { loader = SAXParserFactory.class.getClassLoader(); } String className = null; int count = 0; do { className = getFactoryClassName(loader, count++); if (className != null) { try { Class t = (loader != null) ? loader.loadClass(className) : Class.forName(className); return (SAXParserFactory) t.newInstance(); } catch (ClassNotFoundException e) { className = null; } catch (Exception e) { throw new FactoryConfigurationError(e, "error instantiating class " + className); } } } while (className == null && count < 3); return new gnu.xml.aelfred2.JAXPFactory(); }
public void parse(InputStream stream, DefaultHandler def)
public void parse(InputStream stream, HandlerBase handler)
public void parse(InputStream stream, DefaultHandler def) throws SAXException, IOException { parse (new InputSource (stream), def); }
{ parse (new InputSource (stream), def); }
{ parse (new InputSource (stream), handler); }
public void parse(InputStream stream, DefaultHandler def) throws SAXException, IOException { parse (new InputSource (stream), def); }
if (sr == null) sr = new SizeRequirements(); else { sr.maximum = 0; sr.minimum = 0; sr.preferred = 0; sr.alignment = 0.5F; } int count = getViewCount(); for (int i = 0; i < count; ++i) { View child = getView(i); sr.minimum += child.getMinimumSpan(axis); sr.preferred += child.getPreferredSpan(axis); sr.maximum += child.getMaximumSpan(axis); } return sr;
SizeRequirements[] childReqs = getChildRequirements(axis); return SizeRequirements.getTiledSizeRequirements(childReqs);
protected SizeRequirements calculateMajorAxisRequirements(int axis, SizeRequirements sr) { if (sr == null) sr = new SizeRequirements(); else { sr.maximum = 0; sr.minimum = 0; sr.preferred = 0; sr.alignment = 0.5F; } int count = getViewCount(); // Sum up the sizes of the children along the specified axis. for (int i = 0; i < count; ++i) { View child = getView(i); sr.minimum += child.getMinimumSpan(axis); sr.preferred += child.getPreferredSpan(axis); sr.maximum += child.getMaximumSpan(axis); } return sr; }
if (sr == null) sr = new SizeRequirements(); else { sr.maximum = 0; sr.minimum = 0; sr.preferred = 0; sr.alignment = 0.5F; } int count = getViewCount(); int aboveBaseline = 0; int belowBaseline = 0; int aboveBaselineMin = 0; int belowBaselineMin = 0; int aboveBaselineMax = 0; int belowBaselineMax = 0; for (int i = 0; i < count; ++i) { View child = getView(i); float align = child.getAlignment(axis); int pref = (int) child.getPreferredSpan(axis); int min = (int) child.getMinimumSpan(axis); int max = (int) child.getMaximumSpan(axis); aboveBaseline += (int) (align * pref); belowBaseline += (int) ((1.F - align) * pref); aboveBaselineMin += (int) (align * min); belowBaselineMin += (int) ((1.F - align) * min); aboveBaselineMax += (int) (align * max); belowBaselineMax += (int) ((1.F - align) * max); } sr.minimum = aboveBaselineMin + belowBaselineMin; sr.maximum = aboveBaselineMax + belowBaselineMax; sr.preferred = aboveBaseline + belowBaseline; if (aboveBaseline == 0) sr.alignment = 1.0F; else sr.alignment = (float) (sr.preferred / aboveBaseline); return sr;
SizeRequirements[] childReqs = getChildRequirements(axis); return SizeRequirements.getAlignedSizeRequirements(childReqs);
protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements sr) { if (sr == null) sr = new SizeRequirements(); else { sr.maximum = 0; sr.minimum = 0; sr.preferred = 0; sr.alignment = 0.5F; } int count = getViewCount(); int aboveBaseline = 0; int belowBaseline = 0; int aboveBaselineMin = 0; int belowBaselineMin = 0; int aboveBaselineMax = 0; int belowBaselineMax = 0; for (int i = 0; i < count; ++i) { View child = getView(i); float align = child.getAlignment(axis); int pref = (int) child.getPreferredSpan(axis); int min = (int) child.getMinimumSpan(axis); int max = (int) child.getMaximumSpan(axis); aboveBaseline += (int) (align * pref); belowBaseline += (int) ((1.F - align) * pref); aboveBaselineMin += (int) (align * min); belowBaselineMin += (int) ((1.F - align) * min); aboveBaselineMax += (int) (align * max); belowBaselineMax += (int) ((1.F - align) * max); } sr.minimum = aboveBaselineMin + belowBaselineMin; sr.maximum = aboveBaselineMax + belowBaselineMax; sr.preferred = aboveBaseline + belowBaseline; if (aboveBaseline == 0) sr.alignment = 1.0F; else sr.alignment = (float) (sr.preferred / aboveBaseline); return sr; }
this.width = width; this.height = height; if (myAxis == X_AXIS) { layoutMajorAxis(width, X_AXIS, offsetsX, spansX); layoutMinorAxis(height, Y_AXIS, offsetsY, spansY); } else { layoutMajorAxis(height, Y_AXIS, offsetsY, spansY); layoutMinorAxis(width, X_AXIS, offsetsX, spansX); }
baselineLayout(width, X_AXIS, offsetsX, spansX); baselineLayout(height, Y_AXIS, offsetsY, spansY);
protected void layout(int width, int height) { this.width = width; this.height = height; if (myAxis == X_AXIS) { layoutMajorAxis(width, X_AXIS, offsetsX, spansX); layoutMinorAxis(height, Y_AXIS, offsetsY, spansY); } else { layoutMajorAxis(height, Y_AXIS, offsetsY, spansY); layoutMinorAxis(width, X_AXIS, offsetsX, spansX); } }
int count = getViewCount(); SizeRequirements[] childReqs = new SizeRequirements[count]; for (int i = 0; i < count; ++i) { View view = getView(i); childReqs[i] = new SizeRequirements((int) view.getMinimumSpan(axis), (int) view.getPreferredSpan(axis), (int) view.getMaximumSpan(axis), view.getAlignment(axis)); }
SizeRequirements[] childReqs = getChildRequirements(axis);
protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans) { // Allocate SizeRequirements for each child view. int count = getViewCount(); SizeRequirements[] childReqs = new SizeRequirements[count]; for (int i = 0; i < count; ++i) { View view = getView(i); childReqs[i] = new SizeRequirements((int) view.getMinimumSpan(axis), (int) view.getPreferredSpan(axis), (int) view.getMaximumSpan(axis), view.getAlignment(axis)); } // Calculate the spans and offsets using the SizeRequirements uility // methods. SizeRequirements.calculateTiledPositions(targetSpan, null, childReqs, offsets, spans); validateLayout(axis); }
int count = getViewCount(); SizeRequirements[] childReqs = new SizeRequirements[count]; for (int i = 0; i < count; ++i) { View view = getView(i); childReqs[i] = new SizeRequirements((int) view.getMinimumSpan(axis), (int) view.getPreferredSpan(axis), (int) view.getMaximumSpan(axis), view.getAlignment(axis)); }
SizeRequirements[] childReqs = getChildRequirements(axis);
protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans) { // Allocate SizeRequirements for each child view. int count = getViewCount(); SizeRequirements[] childReqs = new SizeRequirements[count]; for (int i = 0; i < count; ++i) { View view = getView(i); childReqs[i] = new SizeRequirements((int) view.getMinimumSpan(axis), (int) view.getPreferredSpan(axis), (int) view.getMaximumSpan(axis), view.getAlignment(axis)); } // Calculate the spans and offsets using the SizeRequirements uility // methods. SizeRequirements.calculateAlignedPositions(targetSpan, null, childReqs, offsets, spans); validateLayout(axis); }
if (!copy.isEmpty())
public void paint(Graphics g, Shape a) { // Adjust size if the size is changed. Rectangle bounds = a.getBounds(); if (bounds.width != getWidth() || bounds.height != getHeight()) setSize(bounds.width, bounds.height); Rectangle inside = getInsideAllocation(a); Rectangle copy = new Rectangle(inside); int count = getViewCount(); for (int i = 0; i < count; ++i) { copy.setBounds(inside); childAllocation(i, copy); paintChild(g, copy, i); } }
this.width = (int) width; this.height = (int) height;
public void setSize(float width, float height) { if (this.width != (int) width) layoutChanged(X_AXIS); if (this.height != (int) height) layoutChanged(Y_AXIS); Rectangle outside = new Rectangle(0, 0, this.width, this.height); Rectangle inside = getInsideAllocation(outside); if (!isAllocationValid()) layout(inside.width, inside.height); }
public SizeRequirements(int min, int pref, int max, float align) {
public SizeRequirements() {
public SizeRequirements(int min, int pref, int max, float align) { // TODO } // SizeRequirements()
inside.x = alloc.x - insets.left; inside.y = alloc.y - insets.top;
inside.x = alloc.x + insets.left; inside.y = alloc.y + insets.top;
protected Rectangle getInsideAllocation(Shape a) { if (a == null) return null; Rectangle alloc = a.getBounds(); // Initialize the inside allocation rectangle. This is done inside // a synchronized block in order to avoid multiple threads creating // this instance simultanously. Rectangle inside; synchronized(this) { inside = insideAllocation; if (inside == null) { inside = new Rectangle(); insideAllocation = inside; } } inside.x = alloc.x - insets.left; inside.y = alloc.y - insets.top; inside.width = alloc.width - insets.left - insets.right; inside.height = alloc.height - insets.top - insets.bottom; return inside; }
public abstract XMLEventWriter createXMLEventWriter(OutputStream stream)
public abstract XMLEventWriter createXMLEventWriter(Result result)
public abstract XMLEventWriter createXMLEventWriter(OutputStream stream) throws XMLStreamException;
public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader)
public static XMLInputFactory newInstance()
public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError { ClassLoader loader = classLoader; if (loader == null) { loader = Thread.currentThread().getContextClassLoader(); } if (loader == null) { loader = XMLInputFactory.class.getClassLoader(); } String className = null; int count = 0; do { className = getFactoryClassName(loader, count++); if (className != null) { try { Class t = (loader != null) ? loader.loadClass(className) : Class.forName(className); return (XMLInputFactory) t.newInstance(); } catch (ClassNotFoundException e) { className = null; } catch (Exception e) { throw new FactoryConfigurationError(e, "error instantiating class " + className); } } } while (className == null && count < 3); return new gnu.xml.stream.XMLInputFactoryImpl(); }
ClassLoader loader = classLoader; if (loader == null) { loader = Thread.currentThread().getContextClassLoader(); } if (loader == null) { loader = XMLInputFactory.class.getClassLoader(); } String className = null; int count = 0; do { className = getFactoryClassName(loader, count++); if (className != null) { try { Class t = (loader != null) ? loader.loadClass(className) : Class.forName(className); return (XMLInputFactory) t.newInstance(); } catch (ClassNotFoundException e) { className = null; } catch (Exception e) { throw new FactoryConfigurationError(e, "error instantiating class " + className); } } } while (className == null && count < 3); return new gnu.xml.stream.XMLInputFactoryImpl();
return newInstance(null, null);
public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError { ClassLoader loader = classLoader; if (loader == null) { loader = Thread.currentThread().getContextClassLoader(); } if (loader == null) { loader = XMLInputFactory.class.getClassLoader(); } String className = null; int count = 0; do { className = getFactoryClassName(loader, count++); if (className != null) { try { Class t = (loader != null) ? loader.loadClass(className) : Class.forName(className); return (XMLInputFactory) t.newInstance(); } catch (ClassNotFoundException e) { className = null; } catch (Exception e) { throw new FactoryConfigurationError(e, "error instantiating class " + className); } } } while (className == null && count < 3); return new gnu.xml.stream.XMLInputFactoryImpl(); }
return expr._boolean(node, expr.evaluate(node, pos, len));
return Expr._boolean(node, expr.evaluate(node, pos, len));
public boolean matches(Node node, int pos, int len) { Object ret = expr.evaluate(node, pos, len); if (ret instanceof Double) { // Same as [position() = x] return ((Double) ret).intValue() == pos; } return expr._boolean(node, expr.evaluate(node, pos, len)); }
protected AccessibleJSplitPane(JSplitPane component) { super(component); }
protected AccessibleJSplitPane(JSplitPane value0) { super(value0); }
protected AccessibleJSplitPane(JSplitPane component) { super(component); // TODO } // AccessibleJSplitPane()
public AccessibleRole getAccessibleRole() { return AccessibleRole.SPLIT_PANE; }
public AccessibleRole getAccessibleRole() { return null; }
public AccessibleRole getAccessibleRole() { return AccessibleRole.SPLIT_PANE; } // getAccessibleRole()
public JSplitPane() { }
public JSplitPane(int newOrientation, boolean newContinuousLayout, Component newLeftComponent, Component newRightComponent) { if (newOrientation != HORIZONTAL_SPLIT && newOrientation != VERTICAL_SPLIT) throw new IllegalArgumentException("orientation is invalid."); orientation = newOrientation; continuousLayout = newContinuousLayout; setLeftComponent(newLeftComponent); setRightComponent(newRightComponent); updateUI(); }
public JSplitPane() { // TODO } // JSplitPane()
protected void addImpl(Component value0, Object value1, int value2) { }
protected void addImpl(Component comp, Object constraints, int index) { int left = 0; int right = 1; int div = 2; int place; if (constraints == null) { if (leftComponent == null) constraints = LEFT; else if (rightComponent == null) constraints = RIGHT; } if (constraints instanceof String) { String placement = (String) constraints; if (placement.equals(BOTTOM) || placement.equals(RIGHT)) { if (rightComponent != null) remove(rightComponent); rightComponent = comp; } else if (placement.equals(LEFT) || placement.equals(TOP)) { if (leftComponent != null) remove(leftComponent); leftComponent = comp; } else if (placement.equals(DIVIDER)) constraints = null; else throw new IllegalArgumentException("Constraints is not a known identifier."); super.addImpl(comp, constraints, index); } invalidate(); layout(); }
protected void addImpl(Component value0, Object value1, int value2) { // TODO } // addImpl()
public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleJSplitPane(this); } return accessibleContext; }
public AccessibleContext getAccessibleContext() { if (accessibleContext == null) accessibleContext = new AccessibleJSplitPane(this); return accessibleContext; }
public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleJSplitPane(this); } // if return accessibleContext; } // getAccessibleContext()
public Component getBottomComponent() { return null; }
public Component getBottomComponent() { return rightComponent; }
public Component getBottomComponent() { return null; // TODO } // getBottomComponent()
public int getDividerLocation() { return 0; }
public int getDividerLocation() { if (ui != null) return ((SplitPaneUI) ui).getDividerLocation(this); else return -1; }
public int getDividerLocation() { return 0; // TODO } // getDividerLocation()
public int getDividerSize() { return 0; }
public int getDividerSize() { return dividerSize; }
public int getDividerSize() { return 0; // TODO } // getDividerSize()
public int getLastDividerLocation() { return 0; }
public int getLastDividerLocation() { return lastDividerLocation; }
public int getLastDividerLocation() { return 0; // TODO } // getLastDividerLocation()
public Component getLeftComponent() { return null; }
public Component getLeftComponent() { return leftComponent; }
public Component getLeftComponent() { return null; // TODO } // getLeftComponent()
public int getMaximumDividerLocation() { return 0; }
public int getMaximumDividerLocation() { if (ui != null) return ((SplitPaneUI) ui).getMaximumDividerLocation(this); else return -1; }
public int getMaximumDividerLocation() { return 0; // TODO } // getMaximumDividerLocation()
public int getMinimumDividerLocation() { return 0; }
public int getMinimumDividerLocation() { if (ui != null) return ((SplitPaneUI) ui).getMinimumDividerLocation(this); else return -1; }
public int getMinimumDividerLocation() { return 0; // TODO } // getMinimumDividerLocation()
public int getOrientation() { return 0; }
public int getOrientation() { return orientation; }
public int getOrientation() { return 0; // TODO } // getOrientation()
public double getResizeWeight() { return 0.0; }
public double getResizeWeight() { return resizeWeight; }
public double getResizeWeight() { return 0.0; // TODO } // getResizeWeight()
public Component getRightComponent() { return null; }
public Component getRightComponent() { return rightComponent; }
public Component getRightComponent() { return null; // TODO } // getRightComponent()
public Component getTopComponent() { return null; }
public Component getTopComponent() { return leftComponent; }
public Component getTopComponent() { return null; // TODO } // getTopComponent()
public String getUIClassID() { return uiClassID; }
public String getUIClassID() { return "SplitPaneUI"; }
public String getUIClassID() { return uiClassID; } // getUIClassID()
public boolean isContinuousLayout() { return false; }
public boolean isContinuousLayout() { return continuousLayout; }
public boolean isContinuousLayout() { return false; // TODO } // isContinuousLayout()
public boolean isOneTouchExpandable() { return false; }
public boolean isOneTouchExpandable() { return oneTouchExpandable; }
public boolean isOneTouchExpandable() { return false; // TODO } // isOneTouchExpandable()
public boolean isValidateRoot() { return false; }
public boolean isValidateRoot() { return true; }
public boolean isValidateRoot() { return false; // TODO } // isValidateRoot()
protected void paintChildren(Graphics value0) { }
protected void paintChildren(Graphics g) { super.paintChildren(g); if (ui != null) ((SplitPaneUI) ui).finishedPaintingChildren(this, g); }
protected void paintChildren(Graphics value0) { // TODO } // paintChildren()
protected String paramString() { return null; }
protected String paramString() { return "JSplitPane"; }
protected String paramString() { return null; // TODO } // paramString()
public void remove(Component value0) { }
public void remove(Component component) { if (component == leftComponent) leftComponent = null; else if (component == rightComponent) rightComponent = null; super.remove(component); }
public void remove(Component value0) { // TODO } // remove()
public void removeAll() { }
public void removeAll() { leftComponent = null; rightComponent = null; super.removeAll(); }
public void removeAll() { // TODO } // removeAll()
public void resetToPreferredSizes() { }
public void resetToPreferredSizes() { if (ui != null) ((SplitPaneUI) ui).resetToPreferredSizes(this); }
public void resetToPreferredSizes() { // TODO } // resetToPreferredSizes()
public void setBottomComponent(Component value0) { }
public void setBottomComponent(Component comp) { if (comp != null) add(comp, BOTTOM); else add(new JButton("right button"), BOTTOM); }
public void setBottomComponent(Component value0) { // TODO } // setBottomComponent()
public void setContinuousLayout(boolean value0) { }
public void setContinuousLayout(boolean newContinuousLayout) { if (newContinuousLayout != continuousLayout) { boolean oldValue = continuousLayout; continuousLayout = newContinuousLayout; firePropertyChange(CONTINUOUS_LAYOUT_PROPERTY, oldValue, continuousLayout); } }
public void setContinuousLayout(boolean value0) { // TODO } // setContinuousLayout()
public void setDividerLocation(double value0) { }
public void setDividerLocation(double proportionalLocation) { if (proportionalLocation > 1 || proportionalLocation < 0) throw new IllegalArgumentException("proportion has to be between 0 and 1."); int max = (orientation == HORIZONTAL_SPLIT) ? getWidth() : getHeight(); setDividerLocation((int) (proportionalLocation * max)); }
public void setDividerLocation(double value0) { // TODO } // setDividerLocation()
public void setDividerSize(int value0) { }
public void setDividerSize(int newSize) { if (newSize != dividerSize) { int oldSize = dividerSize; dividerSize = newSize; firePropertyChange(DIVIDER_SIZE_PROPERTY, oldSize, dividerSize); } }
public void setDividerSize(int value0) { // TODO } // setDividerSize()
public void setLastDividerLocation(int value0) { }
public void setLastDividerLocation(int newLastLocation) { if (newLastLocation != lastDividerLocation) { int oldValue = lastDividerLocation; lastDividerLocation = newLastLocation; firePropertyChange(LAST_DIVIDER_LOCATION_PROPERTY, oldValue, lastDividerLocation); } }
public void setLastDividerLocation(int value0) { // TODO } // setLastDividerLocation()
public void setLeftComponent(Component value0) { }
public void setLeftComponent(Component comp) { if (comp != null) add(comp, LEFT); else add(new JButton("left button"), LEFT); }
public void setLeftComponent(Component value0) { // TODO } // setLeftComponent()
public void setOneTouchExpandable(boolean value0) { }
public void setOneTouchExpandable(boolean newValue) { if (newValue != oneTouchExpandable) { boolean oldValue = oneTouchExpandable; oneTouchExpandable = newValue; firePropertyChange(ONE_TOUCH_EXPANDABLE_PROPERTY, oldValue, oneTouchExpandable); } }
public void setOneTouchExpandable(boolean value0) { // TODO } // setOneTouchExpandable()
public void setOrientation(int value0) { }
public void setOrientation(int orientation) { if (orientation != HORIZONTAL_SPLIT && orientation != VERTICAL_SPLIT) throw new IllegalArgumentException("orientation must be one of VERTICAL_SPLIT, HORIZONTAL_SPLIT"); if (orientation != this.orientation) { int oldOrientation = this.orientation; this.orientation = orientation; firePropertyChange(ORIENTATION_PROPERTY, oldOrientation, this.orientation); } }
public void setOrientation(int value0) { // TODO } // setOrientation()
public void setResizeWeight(double value0) { }
public void setResizeWeight(double value) { resizeWeight = value; }
public void setResizeWeight(double value0) { // TODO } // setResizeWeight()
public void setRightComponent(Component value0) { }
public void setRightComponent(Component comp) { if (comp != null) add(comp, RIGHT); else add(new JButton("right button"), RIGHT); }
public void setRightComponent(Component value0) { // TODO } // setRightComponent()
public void setTopComponent(Component value0) { }
public void setTopComponent(Component comp) { if (comp != null) add(comp, TOP); else add(new JButton("left button"), TOP); }
public void setTopComponent(Component value0) { // TODO } // setTopComponent()
public void updateUI() { setUI((SplitPaneUI) UIManager.get(this)); invalidate(); }
public void updateUI() { setUI((SplitPaneUI) UIManager.getUI(this)); invalidate(); repaint(); }
public void updateUI() { setUI((SplitPaneUI) UIManager.get(this)); invalidate(); } // updateUI()
path[depth] = node;
path[path.length - depth - 1] = node;
protected TreeNode[] getPathToRoot(TreeNode node, int depth) { if (node == null) { if (depth == 0) return null; return new TreeNode[depth]; } TreeNode[] path = getPathToRoot(node.getParent(), depth + 1); path[depth] = node; return path; }
return (parent == null);
return parent == null;
public boolean isRoot() { return (parent == null); }
if (!inDTD) throw new SAXException("attribute decl outside DTD");
public void attributeDecl(String eName, String aName, String type, String mode, String value) throws SAXException { if (interrupted) { return; } DomDoctype doctype = (DomDoctype) ctx; doctype.attributeDecl(eName, aName, type, mode, value); }
if (!inDTD) throw new SAXException("element decl outside DTD");
public void elementDecl(String name, String model) throws SAXException { if (interrupted) { return; } // Ignore fake element declarations generated by ValidationConsumer. // If an element is not really declared in the DTD it will not be // declared in the document model. if (!(ctx instanceof DomDoctype)) { return; } DomDoctype doctype = (DomDoctype) ctx; doctype.elementDecl(name, model); }
{
public void endEntity(String name) throws SAXException { if ("[dtd]".equals(name) || name.charAt(0) == '%') { // Ignore DTD and parameter entities return; } if ("lt".equals(name) || "gt".equals(name) || "amp".equals(name) || "apos".equals(name) || "quot".equals(name)) { return; } // Get entity Entity entity = popEntity(); // TODO resolve external entities to ensure that entity has content if (expandEntityReferences) { // Get entity content for (Node child = entity.getFirstChild(); child != null; child = child.getNextSibling()) { ctx.appendChild(child); } } else { Node entityReference = doc.createEntityReference(name); ctx.appendChild(entityReference); } }
} if ("lt".equals(name) || "gt".equals(name) || "amp".equals(name) || "apos".equals(name) || "quot".equals(name)) {
if (PREDEFINED_ENTITIES.contains(name))
public void endEntity(String name) throws SAXException { if ("[dtd]".equals(name) || name.charAt(0) == '%') { // Ignore DTD and parameter entities return; } if ("lt".equals(name) || "gt".equals(name) || "amp".equals(name) || "apos".equals(name) || "quot".equals(name)) { return; } // Get entity Entity entity = popEntity(); // TODO resolve external entities to ensure that entity has content if (expandEntityReferences) { // Get entity content for (Node child = entity.getFirstChild(); child != null; child = child.getNextSibling()) { ctx.appendChild(child); } } else { Node entityReference = doc.createEntityReference(name); ctx.appendChild(entityReference); } }
} Entity entity = popEntity();
EntityReference ref = (EntityReference) ctx; if (!ref.getNodeName().equals(name)) throw new SAXException("expecting end of "+ref.getNodeName()+" entity"); ctx = ctx.getParentNode(); if (ref instanceof DomNode) ((DomNode) ref).makeReadonly();
public void endEntity(String name) throws SAXException { if ("[dtd]".equals(name) || name.charAt(0) == '%') { // Ignore DTD and parameter entities return; } if ("lt".equals(name) || "gt".equals(name) || "amp".equals(name) || "apos".equals(name) || "quot".equals(name)) { return; } // Get entity Entity entity = popEntity(); // TODO resolve external entities to ensure that entity has content if (expandEntityReferences) { // Get entity content for (Node child = entity.getFirstChild(); child != null; child = child.getNextSibling()) { ctx.appendChild(child); } } else { Node entityReference = doc.createEntityReference(name); ctx.appendChild(entityReference); } }
for (Node child = entity.getFirstChild(); child != null; child = child.getNextSibling())
Node child = ref.getFirstChild(); while (child != null)
public void endEntity(String name) throws SAXException { if ("[dtd]".equals(name) || name.charAt(0) == '%') { // Ignore DTD and parameter entities return; } if ("lt".equals(name) || "gt".equals(name) || "amp".equals(name) || "apos".equals(name) || "quot".equals(name)) { return; } // Get entity Entity entity = popEntity(); // TODO resolve external entities to ensure that entity has content if (expandEntityReferences) { // Get entity content for (Node child = entity.getFirstChild(); child != null; child = child.getNextSibling()) { ctx.appendChild(child); } } else { Node entityReference = doc.createEntityReference(name); ctx.appendChild(entityReference); } }
} else { Node entityReference = doc.createEntityReference(name); ctx.appendChild(entityReference);
ctx.removeChild(ref);
public void endEntity(String name) throws SAXException { if ("[dtd]".equals(name) || name.charAt(0) == '%') { // Ignore DTD and parameter entities return; } if ("lt".equals(name) || "gt".equals(name) || "amp".equals(name) || "apos".equals(name) || "quot".equals(name)) { return; } // Get entity Entity entity = popEntity(); // TODO resolve external entities to ensure that entity has content if (expandEntityReferences) { // Get entity content for (Node child = entity.getFirstChild(); child != null; child = child.getNextSibling()) { ctx.appendChild(child); } } else { Node entityReference = doc.createEntityReference(name); ctx.appendChild(entityReference); } }
if (!inDTD) throw new SAXException("external entity decl outside DTD");
public void externalEntityDecl(String name, String publicId, String systemId) throws SAXException { if (interrupted) { return; } DomDoctype doctype = (DomDoctype) ctx; Entity entity = doctype.declareEntity(name, publicId, systemId, null); }
if (!inDTD) throw new SAXException("internal entity decl outside DTD");
public void internalEntityDecl(String name, String value) throws SAXException { if (interrupted) { return; } DomDoctype doctype = (DomDoctype) ctx; Entity entity = doctype.declareEntity(name, null, null, null); if (entity != null) { Node text = doc.createTextNode(value); entity.appendChild(text); } }
if (!inDTD) throw new SAXException("notation decl outside DTD");
public void notationDecl(String name, String publicId, String systemId) throws SAXException { if (interrupted) { return; } DomDoctype doctype = (DomDoctype) ctx; doctype.declareNotation(name, publicId, systemId); }
{ ctx = doctype;
public void startEntity(String name) throws SAXException { DocumentType doctype = doc.getDoctype(); if (doctype == null) { throw new SAXException("SAX parser error: " + "reference to entity in undeclared doctype"); } if ("[dtd]".equals(name) || name.charAt(0) == '%') { // Ignore DTD and parameter entities ctx = doctype; return; } if ("lt".equals(name) || "gt".equals(name) || "amp".equals(name) || "apos".equals(name) || "quot".equals(name)) { return; } // Get entity NamedNodeMap entities = doctype.getEntities(); Entity entity = (Entity) entities.getNamedItem(name); if (entity == null) { throw new SAXException("SAX parser error: " + "reference to undeclared entity: " + name); } pushEntity(entity); }
} if ("lt".equals(name) || "gt".equals(name) || "amp".equals(name) || "apos".equals(name) || "quot".equals(name)) {
if (PREDEFINED_ENTITIES.contains(name))
public void startEntity(String name) throws SAXException { DocumentType doctype = doc.getDoctype(); if (doctype == null) { throw new SAXException("SAX parser error: " + "reference to entity in undeclared doctype"); } if ("[dtd]".equals(name) || name.charAt(0) == '%') { // Ignore DTD and parameter entities ctx = doctype; return; } if ("lt".equals(name) || "gt".equals(name) || "amp".equals(name) || "apos".equals(name) || "quot".equals(name)) { return; } // Get entity NamedNodeMap entities = doctype.getEntities(); Entity entity = (Entity) entities.getNamedItem(name); if (entity == null) { throw new SAXException("SAX parser error: " + "reference to undeclared entity: " + name); } pushEntity(entity); }
}
public void startEntity(String name) throws SAXException { DocumentType doctype = doc.getDoctype(); if (doctype == null) { throw new SAXException("SAX parser error: " + "reference to entity in undeclared doctype"); } if ("[dtd]".equals(name) || name.charAt(0) == '%') { // Ignore DTD and parameter entities ctx = doctype; return; } if ("lt".equals(name) || "gt".equals(name) || "amp".equals(name) || "apos".equals(name) || "quot".equals(name)) { return; } // Get entity NamedNodeMap entities = doctype.getEntities(); Entity entity = (Entity) entities.getNamedItem(name); if (entity == null) { throw new SAXException("SAX parser error: " + "reference to undeclared entity: " + name); } pushEntity(entity); }
pushEntity(entity);
EntityReference ref = doc.createEntityReference(name); Node child = ref.getFirstChild(); while (child != null) { Node nextChild = child.getNextSibling(); ref.removeChild(child); child = nextChild; } ctx.appendChild(ref); ctx = ref;
public void startEntity(String name) throws SAXException { DocumentType doctype = doc.getDoctype(); if (doctype == null) { throw new SAXException("SAX parser error: " + "reference to entity in undeclared doctype"); } if ("[dtd]".equals(name) || name.charAt(0) == '%') { // Ignore DTD and parameter entities ctx = doctype; return; } if ("lt".equals(name) || "gt".equals(name) || "amp".equals(name) || "apos".equals(name) || "quot".equals(name)) { return; } // Get entity NamedNodeMap entities = doctype.getEntities(); Entity entity = (Entity) entities.getNamedItem(name); if (entity == null) { throw new SAXException("SAX parser error: " + "reference to undeclared entity: " + name); } pushEntity(entity); }
if (!inDTD) throw new SAXException("unparsed entity decl outside DTD");
public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException { if (interrupted) { return; } DomDoctype doctype = (DomDoctype) ctx; Entity entity = doctype.declareEntity(name, publicId, systemId, notationName); }
public String getUIClassID() { return "JLabel"; }
public String getUIClassID() { return "LabelUI"; }
public String getUIClassID() { return "JLabel"; }
pixel = new int[4];
protected AbstractGraphics2D() { transform = new AffineTransform(); background = Color.WHITE; composite = AlphaComposite.SrcOver; stroke = new BasicStroke(); HashMap hints = new HashMap(); hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT); renderingHints = new RenderingHints(hints); pixel = new int[4]; }
}
public void clearRect(int x, int y, int width, int height) { Paint savedForeground = getPaint(); setPaint(getBackground()); //System.err.println("clearRect transform type: " + transform.getType()); fillRect(x, y, width, height); setPaint(savedForeground); }
throw new UnsupportedOperationException("Not yet implemented");
if (isOptimized) rawCopyArea(x, y, width, height, dx, dy); else copyAreaImpl(x, y, width, height, dx, dy);
public void copyArea(int x, int y, int width, int height, int dx, int dy) { // FIXME: Implement this. throw new UnsupportedOperationException("Not yet implemented"); }
AffineTransform t = new AffineTransform(); t.translate(x, y);
translate(x, y);
public void drawGlyphVector(GlyphVector gv, float x, float y) { int numGlyphs = gv.getNumGlyphs(); AffineTransform t = new AffineTransform(); t.translate(x, y);// // TODO: We could use fill(gv.getOutline()), but that seems to be // slightly more inefficient. for (int i = 0; i < numGlyphs; i++) { //fill(gv.getGlyphVisualBounds(i)); GeneralPath p = new GeneralPath(gv.getGlyphOutline(i)); p.transform(t); //Shape clipped = clipShape(p); //if (clipped != null) // fillShape(clipped, true); // FIXME: Clipping doesn't seem to work correctly. fillShape(p, true); } }
GeneralPath p = new GeneralPath(gv.getGlyphOutline(i)); p.transform(t); fillShape(p, true);
Shape o = gv.getGlyphOutline(i); fillShape(o, true);
public void drawGlyphVector(GlyphVector gv, float x, float y) { int numGlyphs = gv.getNumGlyphs(); AffineTransform t = new AffineTransform(); t.translate(x, y);// // TODO: We could use fill(gv.getOutline()), but that seems to be // slightly more inefficient. for (int i = 0; i < numGlyphs; i++) { //fill(gv.getGlyphVisualBounds(i)); GeneralPath p = new GeneralPath(gv.getGlyphOutline(i)); p.transform(t); //Shape clipped = clipShape(p); //if (clipped != null) // fillShape(clipped, true); // FIXME: Clipping doesn't seem to work correctly. fillShape(p, true); } }
translate(-x, -y);
public void drawGlyphVector(GlyphVector gv, float x, float y) { int numGlyphs = gv.getNumGlyphs(); AffineTransform t = new AffineTransform(); t.translate(x, y);// // TODO: We could use fill(gv.getOutline()), but that seems to be // slightly more inefficient. for (int i = 0; i < numGlyphs; i++) { //fill(gv.getGlyphVisualBounds(i)); GeneralPath p = new GeneralPath(gv.getGlyphOutline(i)); p.transform(t); //Shape clipped = clipShape(p); //if (clipped != null) // fillShape(clipped, true); // FIXME: Clipping doesn't seem to work correctly. fillShape(p, true); } }
throw new UnsupportedOperationException("Not yet implemented");
boolean ret = false; Rectangle areaOfInterest = new Rectangle(0, 0, image.getWidth(obs), image.getHeight(obs)); return drawImageImpl(image, xform, obs, areaOfInterest);
public boolean drawImage(Image image, AffineTransform xform, ImageObserver obs) { // FIXME: Implement this. throw new UnsupportedOperationException("Not yet implemented"); }
throw new UnsupportedOperationException("Not yet implemented");
Rectangle areaOfInterest = new Rectangle((int) image.getMinX(), (int) image.getHeight(), (int) image.getWidth(), (int) image.getHeight()); drawRenderableImageImpl(image, xform, areaOfInterest);
public void drawRenderableImage(RenderableImage image, AffineTransform xform) { // FIXME: Implement this. throw new UnsupportedOperationException("Not yet implemented"); }
throw new UnsupportedOperationException("Not yet implemented");
Rectangle areaOfInterest = new Rectangle(image.getMinX(), image.getHeight(), image.getWidth(), image.getHeight()); drawRenderedImageImpl(image, xform, areaOfInterest);
public void drawRenderedImage(RenderedImage image, AffineTransform xform) { // FIXME: Implement this. throw new UnsupportedOperationException("Not yet implemented"); }
}
public void drawString(String text, int x, int y) { FontRenderContext ctx = getFontRenderContext(); GlyphVector gv = font.createGlyphVector(ctx, text.toCharArray()); drawGlyphVector(gv, x, y); }
cCtx.compose(paintRaster, destinationRaster, destinationRaster);
WritableRaster targetChild = destinationRaster.createWritableTranslatedChild(-x0,- y); cCtx.compose(paintRaster, targetChild, targetChild);
protected void fillScanline(PaintContext pCtx, int x0, int x1, int y) { Raster paintRaster = pCtx.getRaster(x0, y, x1 - x0, 1); ColorModel paintColorModel = pCtx.getColorModel(); CompositeContext cCtx = composite.createContext(paintColorModel, getColorModel(), renderingHints); cCtx.compose(paintRaster, destinationRaster, destinationRaster); updateRaster(destinationRaster, x0, y, x1 - x0, 1); cCtx.dispose(); }
private void fillScanlineAA(int[] alpha, int x0, int y, int numScanlinePixels, PaintContext pCtx)
private void fillScanlineAA(int[] alpha, int x0, int yy, int numPixels, PaintContext pCtx, int offs)
private void fillScanlineAA(int[] alpha, int x0, int y, int numScanlinePixels, PaintContext pCtx) { // FIXME: This doesn't work. Fixit. CompositeContext cCtx = composite.createContext(pCtx.getColorModel(), getColorModel(), renderingHints); Raster paintRaster = pCtx.getRaster(x0, y, numScanlinePixels, 1); System.err.println("paintColorModel: " + pCtx.getColorModel()); WritableRaster aaRaster = paintRaster.createCompatibleWritableRaster(); int numBands = paintRaster.getNumBands(); int[] pixels = new int[numScanlinePixels + paintRaster.getNumBands()]; pixels = paintRaster.getPixels(x0, y, numScanlinePixels, 1, pixels); ColorModel cm = pCtx.getColorModel(); double lastAlpha = 0.; int lastAlphaInt = 0; int[] components = new int[4]; for (int i = 0; i < pixels.length; i++) { if (alpha[i] != 0) { lastAlphaInt += alpha[i]; lastAlpha = lastAlphaInt / AA_SAMPLING; } components = cm.getComponents(pixel[i], components, 0); components[0] = (int) (components[0] * lastAlpha); pixel[i] = cm.getDataElement(components, 0); } aaRaster.setPixels(0, 0, numScanlinePixels, 1, pixels); cCtx.compose(aaRaster, destinationRaster, destinationRaster); updateRaster(destinationRaster, x0, y, numScanlinePixels, 1); cCtx.dispose(); }
Raster paintRaster = pCtx.getRaster(x0, y, numScanlinePixels, 1); System.err.println("paintColorModel: " + pCtx.getColorModel());
Raster paintRaster = pCtx.getRaster(x0, yy, numPixels, 1);
private void fillScanlineAA(int[] alpha, int x0, int y, int numScanlinePixels, PaintContext pCtx) { // FIXME: This doesn't work. Fixit. CompositeContext cCtx = composite.createContext(pCtx.getColorModel(), getColorModel(), renderingHints); Raster paintRaster = pCtx.getRaster(x0, y, numScanlinePixels, 1); System.err.println("paintColorModel: " + pCtx.getColorModel()); WritableRaster aaRaster = paintRaster.createCompatibleWritableRaster(); int numBands = paintRaster.getNumBands(); int[] pixels = new int[numScanlinePixels + paintRaster.getNumBands()]; pixels = paintRaster.getPixels(x0, y, numScanlinePixels, 1, pixels); ColorModel cm = pCtx.getColorModel(); double lastAlpha = 0.; int lastAlphaInt = 0; int[] components = new int[4]; for (int i = 0; i < pixels.length; i++) { if (alpha[i] != 0) { lastAlphaInt += alpha[i]; lastAlpha = lastAlphaInt / AA_SAMPLING; } components = cm.getComponents(pixel[i], components, 0); components[0] = (int) (components[0] * lastAlpha); pixel[i] = cm.getDataElement(components, 0); } aaRaster.setPixels(0, 0, numScanlinePixels, 1, pixels); cCtx.compose(aaRaster, destinationRaster, destinationRaster); updateRaster(destinationRaster, x0, y, numScanlinePixels, 1); cCtx.dispose(); }
int[] pixels = new int[numScanlinePixels + paintRaster.getNumBands()]; pixels = paintRaster.getPixels(x0, y, numScanlinePixels, 1, pixels);
private void fillScanlineAA(int[] alpha, int x0, int y, int numScanlinePixels, PaintContext pCtx) { // FIXME: This doesn't work. Fixit. CompositeContext cCtx = composite.createContext(pCtx.getColorModel(), getColorModel(), renderingHints); Raster paintRaster = pCtx.getRaster(x0, y, numScanlinePixels, 1); System.err.println("paintColorModel: " + pCtx.getColorModel()); WritableRaster aaRaster = paintRaster.createCompatibleWritableRaster(); int numBands = paintRaster.getNumBands(); int[] pixels = new int[numScanlinePixels + paintRaster.getNumBands()]; pixels = paintRaster.getPixels(x0, y, numScanlinePixels, 1, pixels); ColorModel cm = pCtx.getColorModel(); double lastAlpha = 0.; int lastAlphaInt = 0; int[] components = new int[4]; for (int i = 0; i < pixels.length; i++) { if (alpha[i] != 0) { lastAlphaInt += alpha[i]; lastAlpha = lastAlphaInt / AA_SAMPLING; } components = cm.getComponents(pixel[i], components, 0); components[0] = (int) (components[0] * lastAlpha); pixel[i] = cm.getDataElement(components, 0); } aaRaster.setPixels(0, 0, numScanlinePixels, 1, pixels); cCtx.compose(aaRaster, destinationRaster, destinationRaster); updateRaster(destinationRaster, x0, y, numScanlinePixels, 1); cCtx.dispose(); }
int[] components = new int[4];
private void fillScanlineAA(int[] alpha, int x0, int y, int numScanlinePixels, PaintContext pCtx) { // FIXME: This doesn't work. Fixit. CompositeContext cCtx = composite.createContext(pCtx.getColorModel(), getColorModel(), renderingHints); Raster paintRaster = pCtx.getRaster(x0, y, numScanlinePixels, 1); System.err.println("paintColorModel: " + pCtx.getColorModel()); WritableRaster aaRaster = paintRaster.createCompatibleWritableRaster(); int numBands = paintRaster.getNumBands(); int[] pixels = new int[numScanlinePixels + paintRaster.getNumBands()]; pixels = paintRaster.getPixels(x0, y, numScanlinePixels, 1, pixels); ColorModel cm = pCtx.getColorModel(); double lastAlpha = 0.; int lastAlphaInt = 0; int[] components = new int[4]; for (int i = 0; i < pixels.length; i++) { if (alpha[i] != 0) { lastAlphaInt += alpha[i]; lastAlpha = lastAlphaInt / AA_SAMPLING; } components = cm.getComponents(pixel[i], components, 0); components[0] = (int) (components[0] * lastAlpha); pixel[i] = cm.getDataElement(components, 0); } aaRaster.setPixels(0, 0, numScanlinePixels, 1, pixels); cCtx.compose(aaRaster, destinationRaster, destinationRaster); updateRaster(destinationRaster, x0, y, numScanlinePixels, 1); cCtx.dispose(); }
for (int i = 0; i < pixels.length; i++)
Object pixel = null; int[] comps = null; int x1 = x0 + numPixels; for (int x = x0; x < x1; x++)
private void fillScanlineAA(int[] alpha, int x0, int y, int numScanlinePixels, PaintContext pCtx) { // FIXME: This doesn't work. Fixit. CompositeContext cCtx = composite.createContext(pCtx.getColorModel(), getColorModel(), renderingHints); Raster paintRaster = pCtx.getRaster(x0, y, numScanlinePixels, 1); System.err.println("paintColorModel: " + pCtx.getColorModel()); WritableRaster aaRaster = paintRaster.createCompatibleWritableRaster(); int numBands = paintRaster.getNumBands(); int[] pixels = new int[numScanlinePixels + paintRaster.getNumBands()]; pixels = paintRaster.getPixels(x0, y, numScanlinePixels, 1, pixels); ColorModel cm = pCtx.getColorModel(); double lastAlpha = 0.; int lastAlphaInt = 0; int[] components = new int[4]; for (int i = 0; i < pixels.length; i++) { if (alpha[i] != 0) { lastAlphaInt += alpha[i]; lastAlpha = lastAlphaInt / AA_SAMPLING; } components = cm.getComponents(pixel[i], components, 0); components[0] = (int) (components[0] * lastAlpha); pixel[i] = cm.getDataElement(components, 0); } aaRaster.setPixels(0, 0, numScanlinePixels, 1, pixels); cCtx.compose(aaRaster, destinationRaster, destinationRaster); updateRaster(destinationRaster, x0, y, numScanlinePixels, 1); cCtx.dispose(); }
lastAlpha = lastAlphaInt / AA_SAMPLING;
lastAlpha = (double) lastAlphaInt / (double) AA_SAMPLING; alpha[i] = 0;
private void fillScanlineAA(int[] alpha, int x0, int y, int numScanlinePixels, PaintContext pCtx) { // FIXME: This doesn't work. Fixit. CompositeContext cCtx = composite.createContext(pCtx.getColorModel(), getColorModel(), renderingHints); Raster paintRaster = pCtx.getRaster(x0, y, numScanlinePixels, 1); System.err.println("paintColorModel: " + pCtx.getColorModel()); WritableRaster aaRaster = paintRaster.createCompatibleWritableRaster(); int numBands = paintRaster.getNumBands(); int[] pixels = new int[numScanlinePixels + paintRaster.getNumBands()]; pixels = paintRaster.getPixels(x0, y, numScanlinePixels, 1, pixels); ColorModel cm = pCtx.getColorModel(); double lastAlpha = 0.; int lastAlphaInt = 0; int[] components = new int[4]; for (int i = 0; i < pixels.length; i++) { if (alpha[i] != 0) { lastAlphaInt += alpha[i]; lastAlpha = lastAlphaInt / AA_SAMPLING; } components = cm.getComponents(pixel[i], components, 0); components[0] = (int) (components[0] * lastAlpha); pixel[i] = cm.getDataElement(components, 0); } aaRaster.setPixels(0, 0, numScanlinePixels, 1, pixels); cCtx.compose(aaRaster, destinationRaster, destinationRaster); updateRaster(destinationRaster, x0, y, numScanlinePixels, 1); cCtx.dispose(); }
components = cm.getComponents(pixel[i], components, 0); components[0] = (int) (components[0] * lastAlpha); pixel[i] = cm.getDataElement(components, 0);
pixel = paintRaster.getDataElements(x - x0, 0, pixel); comps = cm.getComponents(pixel, comps, 0); if (cm.hasAlpha() && ! cm.isAlphaPremultiplied()) comps[comps.length - 1] *= lastAlpha; else { int max; if (cm.hasAlpha()) max = comps.length - 2; else max = comps.length - 1; for (int j = 0; j < max; j++) comps[j] *= lastAlpha; } pixel = cm.getDataElements(comps, 0, pixel); aaRaster.setDataElements(x - x0, 0, pixel);
private void fillScanlineAA(int[] alpha, int x0, int y, int numScanlinePixels, PaintContext pCtx) { // FIXME: This doesn't work. Fixit. CompositeContext cCtx = composite.createContext(pCtx.getColorModel(), getColorModel(), renderingHints); Raster paintRaster = pCtx.getRaster(x0, y, numScanlinePixels, 1); System.err.println("paintColorModel: " + pCtx.getColorModel()); WritableRaster aaRaster = paintRaster.createCompatibleWritableRaster(); int numBands = paintRaster.getNumBands(); int[] pixels = new int[numScanlinePixels + paintRaster.getNumBands()]; pixels = paintRaster.getPixels(x0, y, numScanlinePixels, 1, pixels); ColorModel cm = pCtx.getColorModel(); double lastAlpha = 0.; int lastAlphaInt = 0; int[] components = new int[4]; for (int i = 0; i < pixels.length; i++) { if (alpha[i] != 0) { lastAlphaInt += alpha[i]; lastAlpha = lastAlphaInt / AA_SAMPLING; } components = cm.getComponents(pixel[i], components, 0); components[0] = (int) (components[0] * lastAlpha); pixel[i] = cm.getDataElement(components, 0); } aaRaster.setPixels(0, 0, numScanlinePixels, 1, pixels); cCtx.compose(aaRaster, destinationRaster, destinationRaster); updateRaster(destinationRaster, x0, y, numScanlinePixels, 1); cCtx.dispose(); }
aaRaster.setPixels(0, 0, numScanlinePixels, 1, pixels); cCtx.compose(aaRaster, destinationRaster, destinationRaster); updateRaster(destinationRaster, x0, y, numScanlinePixels, 1);
WritableRaster targetChild = destinationRaster.createWritableTranslatedChild(-x0, -yy); cCtx.compose(aaRaster, targetChild, targetChild); updateRaster(destinationRaster, x0, yy, numPixels, 1);
private void fillScanlineAA(int[] alpha, int x0, int y, int numScanlinePixels, PaintContext pCtx) { // FIXME: This doesn't work. Fixit. CompositeContext cCtx = composite.createContext(pCtx.getColorModel(), getColorModel(), renderingHints); Raster paintRaster = pCtx.getRaster(x0, y, numScanlinePixels, 1); System.err.println("paintColorModel: " + pCtx.getColorModel()); WritableRaster aaRaster = paintRaster.createCompatibleWritableRaster(); int numBands = paintRaster.getNumBands(); int[] pixels = new int[numScanlinePixels + paintRaster.getNumBands()]; pixels = paintRaster.getPixels(x0, y, numScanlinePixels, 1, pixels); ColorModel cm = pCtx.getColorModel(); double lastAlpha = 0.; int lastAlphaInt = 0; int[] components = new int[4]; for (int i = 0; i < pixels.length; i++) { if (alpha[i] != 0) { lastAlphaInt += alpha[i]; lastAlpha = lastAlphaInt / AA_SAMPLING; } components = cm.getComponents(pixel[i], components, 0); components[0] = (int) (components[0] * lastAlpha); pixel[i] = cm.getDataElement(components, 0); } aaRaster.setPixels(0, 0, numScanlinePixels, 1, pixels); cCtx.compose(aaRaster, destinationRaster, destinationRaster); updateRaster(destinationRaster, x0, y, numScanlinePixels, 1); cCtx.dispose(); }
antialias = (v == RenderingHints.VALUE_TEXT_ANTIALIAS_ON || v == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
antialias = (v == RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
protected void fillShape(Shape s, boolean isFont) { // Determine if we need to antialias stuff. boolean antialias = false; if (isFont) { Object v = renderingHints.get(RenderingHints.KEY_TEXT_ANTIALIASING); // We default to antialiasing on for text as long as we have no // good hinting implemented. antialias = (v == RenderingHints.VALUE_TEXT_ANTIALIAS_ON || v == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); } else { Object v = renderingHints.get(RenderingHints.KEY_ANTIALIASING); antialias = (v == RenderingHints.VALUE_ANTIALIAS_ON); } Rectangle2D userBounds = s.getBounds2D(); // Flatten the path. TODO: Determine the best flattening factor // wrt to speed and quality. PathIterator path = s.getPathIterator(getTransform(), 1.0); // Build up polygons and let the native backend render this using // rawFillShape() which would provide a default implementation for // drawPixel using a PolyScan algorithm. double[] seg = new double[6]; // TODO: Use ArrayList<PolyEdge> here when availble. ArrayList segs = new ArrayList(); double segX = 0.; // The start point of the current edge. double segY = 0.; double polyX = 0.; // The start point of the current polygon. double polyY = 0.; double minX = Integer.MAX_VALUE; double maxX = Integer.MIN_VALUE; double minY = Integer.MAX_VALUE; double maxY = Integer.MIN_VALUE; //System.err.println("fill polygon"); while (! path.isDone()) { int segType = path.currentSegment(seg); minX = Math.min(minX, seg[0]); maxX = Math.max(maxX, seg[0]); minY = Math.min(minY, seg[1]); maxY = Math.max(maxY, seg[1]); //System.err.println("segment: " + segType + ", " + seg[0] + ", " + seg[1]); if (segType == PathIterator.SEG_MOVETO) { segX = seg[0]; segY = seg[1]; polyX = seg[0]; polyY = seg[1]; } else if (segType == PathIterator.SEG_CLOSE) { // Close the polyline. PolyEdge edge = new PolyEdge(segX, segY, polyX, polyY); segs.add(edge); } else if (segType == PathIterator.SEG_LINETO) { PolyEdge edge = new PolyEdge(segX, segY, seg[0], seg[1]); segs.add(edge); segX = seg[0]; segY = seg[1]; } path.next(); } if (segs.size() > 0) { if (antialias) fillShapeAntialias(segs, minX, minY, maxX, maxY, userBounds); else rawFillShape(segs, minX, minY, maxX, maxY, userBounds); } }
PathIterator path = s.getPathIterator(getTransform(), 1.0); double[] seg = new double[6]; ArrayList segs = new ArrayList(); double segX = 0.; double segY = 0.; double polyX = 0.; double polyY = 0.; double minX = Integer.MAX_VALUE; double maxX = Integer.MIN_VALUE; double minY = Integer.MAX_VALUE; double maxY = Integer.MIN_VALUE; while (! path.isDone()) { int segType = path.currentSegment(seg); minX = Math.min(minX, seg[0]); maxX = Math.max(maxX, seg[0]); minY = Math.min(minY, seg[1]); maxY = Math.max(maxY, seg[1]); if (segType == PathIterator.SEG_MOVETO) { segX = seg[0]; segY = seg[1]; polyX = seg[0]; polyY = seg[1]; } else if (segType == PathIterator.SEG_CLOSE) { PolyEdge edge = new PolyEdge(segX, segY, polyX, polyY); segs.add(edge); } else if (segType == PathIterator.SEG_LINETO) { PolyEdge edge = new PolyEdge(segX, segY, seg[0], seg[1]); segs.add(edge); segX = seg[0]; segY = seg[1]; } path.next(); }
Rectangle2D deviceBounds = new Rectangle2D.Double(); ArrayList segs = getSegments(s, transform, deviceBounds, false); Rectangle2D clipBounds = new Rectangle2D.Double(); ArrayList clipSegs = getSegments(clip, transform, clipBounds, true); segs.addAll(clipSegs); Rectangle2D inclClipBounds = new Rectangle2D.Double(); Rectangle2D.union(clipBounds, deviceBounds, inclClipBounds);
protected void fillShape(Shape s, boolean isFont) { // Determine if we need to antialias stuff. boolean antialias = false; if (isFont) { Object v = renderingHints.get(RenderingHints.KEY_TEXT_ANTIALIASING); // We default to antialiasing on for text as long as we have no // good hinting implemented. antialias = (v == RenderingHints.VALUE_TEXT_ANTIALIAS_ON || v == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); } else { Object v = renderingHints.get(RenderingHints.KEY_ANTIALIASING); antialias = (v == RenderingHints.VALUE_ANTIALIAS_ON); } Rectangle2D userBounds = s.getBounds2D(); // Flatten the path. TODO: Determine the best flattening factor // wrt to speed and quality. PathIterator path = s.getPathIterator(getTransform(), 1.0); // Build up polygons and let the native backend render this using // rawFillShape() which would provide a default implementation for // drawPixel using a PolyScan algorithm. double[] seg = new double[6]; // TODO: Use ArrayList<PolyEdge> here when availble. ArrayList segs = new ArrayList(); double segX = 0.; // The start point of the current edge. double segY = 0.; double polyX = 0.; // The start point of the current polygon. double polyY = 0.; double minX = Integer.MAX_VALUE; double maxX = Integer.MIN_VALUE; double minY = Integer.MAX_VALUE; double maxY = Integer.MIN_VALUE; //System.err.println("fill polygon"); while (! path.isDone()) { int segType = path.currentSegment(seg); minX = Math.min(minX, seg[0]); maxX = Math.max(maxX, seg[0]); minY = Math.min(minY, seg[1]); maxY = Math.max(maxY, seg[1]); //System.err.println("segment: " + segType + ", " + seg[0] + ", " + seg[1]); if (segType == PathIterator.SEG_MOVETO) { segX = seg[0]; segY = seg[1]; polyX = seg[0]; polyY = seg[1]; } else if (segType == PathIterator.SEG_CLOSE) { // Close the polyline. PolyEdge edge = new PolyEdge(segX, segY, polyX, polyY); segs.add(edge); } else if (segType == PathIterator.SEG_LINETO) { PolyEdge edge = new PolyEdge(segX, segY, seg[0], seg[1]); segs.add(edge); segX = seg[0]; segY = seg[1]; } path.next(); } if (segs.size() > 0) { if (antialias) fillShapeAntialias(segs, minX, minY, maxX, maxY, userBounds); else rawFillShape(segs, minX, minY, maxX, maxY, userBounds); } }
fillShapeAntialias(segs, minX, minY, maxX, maxY, userBounds);
fillShapeAntialias(segs, deviceBounds, userBounds, inclClipBounds);
protected void fillShape(Shape s, boolean isFont) { // Determine if we need to antialias stuff. boolean antialias = false; if (isFont) { Object v = renderingHints.get(RenderingHints.KEY_TEXT_ANTIALIASING); // We default to antialiasing on for text as long as we have no // good hinting implemented. antialias = (v == RenderingHints.VALUE_TEXT_ANTIALIAS_ON || v == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); } else { Object v = renderingHints.get(RenderingHints.KEY_ANTIALIASING); antialias = (v == RenderingHints.VALUE_ANTIALIAS_ON); } Rectangle2D userBounds = s.getBounds2D(); // Flatten the path. TODO: Determine the best flattening factor // wrt to speed and quality. PathIterator path = s.getPathIterator(getTransform(), 1.0); // Build up polygons and let the native backend render this using // rawFillShape() which would provide a default implementation for // drawPixel using a PolyScan algorithm. double[] seg = new double[6]; // TODO: Use ArrayList<PolyEdge> here when availble. ArrayList segs = new ArrayList(); double segX = 0.; // The start point of the current edge. double segY = 0.; double polyX = 0.; // The start point of the current polygon. double polyY = 0.; double minX = Integer.MAX_VALUE; double maxX = Integer.MIN_VALUE; double minY = Integer.MAX_VALUE; double maxY = Integer.MIN_VALUE; //System.err.println("fill polygon"); while (! path.isDone()) { int segType = path.currentSegment(seg); minX = Math.min(minX, seg[0]); maxX = Math.max(maxX, seg[0]); minY = Math.min(minY, seg[1]); maxY = Math.max(maxY, seg[1]); //System.err.println("segment: " + segType + ", " + seg[0] + ", " + seg[1]); if (segType == PathIterator.SEG_MOVETO) { segX = seg[0]; segY = seg[1]; polyX = seg[0]; polyY = seg[1]; } else if (segType == PathIterator.SEG_CLOSE) { // Close the polyline. PolyEdge edge = new PolyEdge(segX, segY, polyX, polyY); segs.add(edge); } else if (segType == PathIterator.SEG_LINETO) { PolyEdge edge = new PolyEdge(segX, segY, seg[0], seg[1]); segs.add(edge); segX = seg[0]; segY = seg[1]; } path.next(); } if (segs.size() > 0) { if (antialias) fillShapeAntialias(segs, minX, minY, maxX, maxY, userBounds); else rawFillShape(segs, minX, minY, maxX, maxY, userBounds); } }
rawFillShape(segs, minX, minY, maxX, maxY, userBounds);
fillShapeImpl(segs, deviceBounds, userBounds, inclClipBounds);
protected void fillShape(Shape s, boolean isFont) { // Determine if we need to antialias stuff. boolean antialias = false; if (isFont) { Object v = renderingHints.get(RenderingHints.KEY_TEXT_ANTIALIASING); // We default to antialiasing on for text as long as we have no // good hinting implemented. antialias = (v == RenderingHints.VALUE_TEXT_ANTIALIAS_ON || v == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); } else { Object v = renderingHints.get(RenderingHints.KEY_ANTIALIASING); antialias = (v == RenderingHints.VALUE_ANTIALIAS_ON); } Rectangle2D userBounds = s.getBounds2D(); // Flatten the path. TODO: Determine the best flattening factor // wrt to speed and quality. PathIterator path = s.getPathIterator(getTransform(), 1.0); // Build up polygons and let the native backend render this using // rawFillShape() which would provide a default implementation for // drawPixel using a PolyScan algorithm. double[] seg = new double[6]; // TODO: Use ArrayList<PolyEdge> here when availble. ArrayList segs = new ArrayList(); double segX = 0.; // The start point of the current edge. double segY = 0.; double polyX = 0.; // The start point of the current polygon. double polyY = 0.; double minX = Integer.MAX_VALUE; double maxX = Integer.MIN_VALUE; double minY = Integer.MAX_VALUE; double maxY = Integer.MIN_VALUE; //System.err.println("fill polygon"); while (! path.isDone()) { int segType = path.currentSegment(seg); minX = Math.min(minX, seg[0]); maxX = Math.max(maxX, seg[0]); minY = Math.min(minY, seg[1]); maxY = Math.max(maxY, seg[1]); //System.err.println("segment: " + segType + ", " + seg[0] + ", " + seg[1]); if (segType == PathIterator.SEG_MOVETO) { segX = seg[0]; segY = seg[1]; polyX = seg[0]; polyY = seg[1]; } else if (segType == PathIterator.SEG_CLOSE) { // Close the polyline. PolyEdge edge = new PolyEdge(segX, segY, polyX, polyY); segs.add(edge); } else if (segType == PathIterator.SEG_LINETO) { PolyEdge edge = new PolyEdge(segX, segY, seg[0], seg[1]); segs.add(edge); segX = seg[0]; segY = seg[1]; } path.next(); } if (segs.size() > 0) { if (antialias) fillShapeAntialias(segs, minX, minY, maxX, maxY, userBounds); else rawFillShape(segs, minX, minY, maxX, maxY, userBounds); } }
private void fillShapeAntialias(ArrayList segs, double minX, double minY, double maxX, double maxY, Rectangle2D userBounds)
private void fillShapeAntialias(ArrayList segs, Rectangle2D deviceBounds2D, Rectangle2D userBounds, Rectangle2D inclClipBounds)
private void fillShapeAntialias(ArrayList segs, double minX, double minY, double maxX, double maxY, Rectangle2D userBounds) { // This is an implementation of a polygon scanline conversion algorithm // described here: // http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/scan/ // The antialiasing is implemented using a sampling technique, we do // not scan whole lines but fractions of the line. Rectangle deviceBounds = new Rectangle((int) minX, (int) minY, (int) Math.ceil(maxX) - (int) minX, (int) Math.ceil(maxY) - (int) minY); PaintContext pCtx = paint.createContext(getColorModel(), deviceBounds, userBounds, transform, renderingHints); // This array will contain the oversampled transparency values for // each pixel in the scanline. int numScanlines = (int) Math.ceil(maxY) - (int) minY; int numScanlinePixels = (int) Math.ceil(maxX) - (int) minX + 1; if (alpha == null || alpha.length < (numScanlinePixels + 1)) alpha = new int[numScanlinePixels + 1]; int firstLine = (int) minY; //System.err.println("minY: " + minY); int firstSubline = (int) (Math.ceil((minY - Math.floor(minY)) * AA_SAMPLING)); double firstLineDouble = firstLine + firstSubline / (double) AA_SAMPLING; //System.err.println("firstSubline: " + firstSubline); // Create table of all edges. // The edge buckets, sorted and indexed by their Y values. //System.err.println("numScanlines: " + numScanlines); if (edgeTable == null || edgeTable.length < numScanlines * AA_SAMPLING + AA_SAMPLING) edgeTable = new ArrayList[numScanlines * AA_SAMPLING + AA_SAMPLING]; //System.err.println("firstLineDouble: " + firstLineDouble); for (Iterator i = segs.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); int yindex = (int) (Math.ceil((edge.y0 - firstLineDouble) * AA_SAMPLING)); //System.err.println("yindex: " + yindex + " for y0: " + edge.y0); // Initialize edge's slope and initial xIntersection. edge.slope = ((edge.x1 - edge.x0) / (edge.y1 - edge.y0)) / AA_SAMPLING; if (edge.y0 == edge.y1) // Horizontal edge. edge.xIntersection = Math.min(edge.x0, edge.x1); else { double alignedFirst = Math.ceil(edge.y0 * AA_SAMPLING) / AA_SAMPLING; edge.xIntersection = edge.x0 + (edge.slope * AA_SAMPLING) * (alignedFirst - edge.y0); } //System.err.println(edge); // FIXME: Sanity check should not be needed when clipping works. if (yindex >= 0 && yindex < edgeTable.length) { if (edgeTable[yindex] == null) // Create bucket when needed. edgeTable[yindex] = new ArrayList(); edgeTable[yindex].add(edge); // Add edge to the bucket of its line. } } // The activeEdges list contains all the edges of the current scanline // ordered by their intersection points with this scanline. ArrayList activeEdges = new ArrayList(); PolyEdgeComparator comparator = new PolyEdgeComparator(); // Scan all lines. int yindex = 0; //System.err.println("firstLine: " + firstLine + ", maxY: " + maxY + ", firstSubline: " + firstSubline); for (int y = firstLine; y <= maxY; y++) { for (int subY = firstSubline; subY < AA_SAMPLING; subY++) { //System.err.println("scanline: " + y + ", subScanline: " + subY); ArrayList bucket = edgeTable[yindex]; // Update all the x intersections in the current activeEdges table // and remove entries that are no longer in the scanline. for (Iterator i = activeEdges.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); // TODO: Do the following using integer arithmetics. if ((y + ((double) subY / (double) AA_SAMPLING)) > edge.y1) i.remove(); else { edge.xIntersection += edge.slope; //System.err.println("edge: " + edge); //edge.xIntersection = edge.x0 + edge.slope * (y - edge.y0); //System.err.println("edge.xIntersection: " + edge.xIntersection); } } if (bucket != null) { activeEdges.addAll(bucket); edgeTable[yindex].clear(); } // Sort current edges. We are using a bubble sort, because the order // of the intersections will not change in most situations. They // will only change, when edges intersect each other. int size = activeEdges.size(); if (size > 1) { for (int i = 1; i < size; i++) { PolyEdge e1 = (PolyEdge) activeEdges.get(i - 1); PolyEdge e2 = (PolyEdge) activeEdges.get(i); if (comparator.compare(e1, e2) > 0) { // Swap e2 with its left neighbor until it 'fits'. int j = i; do { activeEdges.set(j, e1); activeEdges.set(j - 1, e2); j--; if (j >= 1) e1 = (PolyEdge) activeEdges.get(j - 1); } while (j >= 1 && comparator.compare(e1, e2) > 0); } } } // Now draw all pixels inside the polygon. // This is the last edge that intersected the scanline. PolyEdge previous = null; // Gets initialized below. boolean active = false; //System.err.println("scanline: " + y + ", subscanline: " + subY); for (Iterator i = activeEdges.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); // Only fill scanline, if the current edge actually intersects // the scanline. There may be edges that lie completely // within the current scanline. //System.err.println("previous: " + previous); //System.err.println("edge: " + edge); if (active) { // TODO: Use integer arithmetics here. if (edge.y1 > (y + (subY / (double) AA_SAMPLING))) { //System.err.println(edge); // TODO: Eliminate the aligments. int x0 = (int) Math.min(Math.max(previous.xIntersection, minX), maxX); int x1 = (int) Math.min(Math.max(edge.xIntersection, minX), maxX); //System.err.println("minX: " + minX + ", x0: " + x0 + ", x1: " + x1 + ", maxX: " + maxX); // TODO: Pull out cast. alpha[x0 - (int) minX]++; alpha[x1 - (int) minX + 1]--; previous = edge; active = false; } } else { // TODO: Use integer arithmetics here. if (edge.y1 > (y + (subY / (double) AA_SAMPLING))) { //System.err.println(edge); previous = edge; active = true; } } } yindex++; } firstSubline = 0; // Render full scanline. //System.err.println("scanline: " + y); fillScanlineAA(alpha, (int) minX, (int) y, numScanlinePixels, pCtx); } if (paint instanceof Color && composite == AlphaComposite.SrcOver) rawSetForeground((Color) paint); pCtx.dispose(); }
PaintContext pCtx = paint.createContext(getColorModel(), deviceBounds,
PaintContext pCtx = paint.createContext(ColorModel.getRGBdefault(), deviceBounds,
private void fillShapeAntialias(ArrayList segs, double minX, double minY, double maxX, double maxY, Rectangle2D userBounds) { // This is an implementation of a polygon scanline conversion algorithm // described here: // http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/scan/ // The antialiasing is implemented using a sampling technique, we do // not scan whole lines but fractions of the line. Rectangle deviceBounds = new Rectangle((int) minX, (int) minY, (int) Math.ceil(maxX) - (int) minX, (int) Math.ceil(maxY) - (int) minY); PaintContext pCtx = paint.createContext(getColorModel(), deviceBounds, userBounds, transform, renderingHints); // This array will contain the oversampled transparency values for // each pixel in the scanline. int numScanlines = (int) Math.ceil(maxY) - (int) minY; int numScanlinePixels = (int) Math.ceil(maxX) - (int) minX + 1; if (alpha == null || alpha.length < (numScanlinePixels + 1)) alpha = new int[numScanlinePixels + 1]; int firstLine = (int) minY; //System.err.println("minY: " + minY); int firstSubline = (int) (Math.ceil((minY - Math.floor(minY)) * AA_SAMPLING)); double firstLineDouble = firstLine + firstSubline / (double) AA_SAMPLING; //System.err.println("firstSubline: " + firstSubline); // Create table of all edges. // The edge buckets, sorted and indexed by their Y values. //System.err.println("numScanlines: " + numScanlines); if (edgeTable == null || edgeTable.length < numScanlines * AA_SAMPLING + AA_SAMPLING) edgeTable = new ArrayList[numScanlines * AA_SAMPLING + AA_SAMPLING]; //System.err.println("firstLineDouble: " + firstLineDouble); for (Iterator i = segs.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); int yindex = (int) (Math.ceil((edge.y0 - firstLineDouble) * AA_SAMPLING)); //System.err.println("yindex: " + yindex + " for y0: " + edge.y0); // Initialize edge's slope and initial xIntersection. edge.slope = ((edge.x1 - edge.x0) / (edge.y1 - edge.y0)) / AA_SAMPLING; if (edge.y0 == edge.y1) // Horizontal edge. edge.xIntersection = Math.min(edge.x0, edge.x1); else { double alignedFirst = Math.ceil(edge.y0 * AA_SAMPLING) / AA_SAMPLING; edge.xIntersection = edge.x0 + (edge.slope * AA_SAMPLING) * (alignedFirst - edge.y0); } //System.err.println(edge); // FIXME: Sanity check should not be needed when clipping works. if (yindex >= 0 && yindex < edgeTable.length) { if (edgeTable[yindex] == null) // Create bucket when needed. edgeTable[yindex] = new ArrayList(); edgeTable[yindex].add(edge); // Add edge to the bucket of its line. } } // The activeEdges list contains all the edges of the current scanline // ordered by their intersection points with this scanline. ArrayList activeEdges = new ArrayList(); PolyEdgeComparator comparator = new PolyEdgeComparator(); // Scan all lines. int yindex = 0; //System.err.println("firstLine: " + firstLine + ", maxY: " + maxY + ", firstSubline: " + firstSubline); for (int y = firstLine; y <= maxY; y++) { for (int subY = firstSubline; subY < AA_SAMPLING; subY++) { //System.err.println("scanline: " + y + ", subScanline: " + subY); ArrayList bucket = edgeTable[yindex]; // Update all the x intersections in the current activeEdges table // and remove entries that are no longer in the scanline. for (Iterator i = activeEdges.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); // TODO: Do the following using integer arithmetics. if ((y + ((double) subY / (double) AA_SAMPLING)) > edge.y1) i.remove(); else { edge.xIntersection += edge.slope; //System.err.println("edge: " + edge); //edge.xIntersection = edge.x0 + edge.slope * (y - edge.y0); //System.err.println("edge.xIntersection: " + edge.xIntersection); } } if (bucket != null) { activeEdges.addAll(bucket); edgeTable[yindex].clear(); } // Sort current edges. We are using a bubble sort, because the order // of the intersections will not change in most situations. They // will only change, when edges intersect each other. int size = activeEdges.size(); if (size > 1) { for (int i = 1; i < size; i++) { PolyEdge e1 = (PolyEdge) activeEdges.get(i - 1); PolyEdge e2 = (PolyEdge) activeEdges.get(i); if (comparator.compare(e1, e2) > 0) { // Swap e2 with its left neighbor until it 'fits'. int j = i; do { activeEdges.set(j, e1); activeEdges.set(j - 1, e2); j--; if (j >= 1) e1 = (PolyEdge) activeEdges.get(j - 1); } while (j >= 1 && comparator.compare(e1, e2) > 0); } } } // Now draw all pixels inside the polygon. // This is the last edge that intersected the scanline. PolyEdge previous = null; // Gets initialized below. boolean active = false; //System.err.println("scanline: " + y + ", subscanline: " + subY); for (Iterator i = activeEdges.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); // Only fill scanline, if the current edge actually intersects // the scanline. There may be edges that lie completely // within the current scanline. //System.err.println("previous: " + previous); //System.err.println("edge: " + edge); if (active) { // TODO: Use integer arithmetics here. if (edge.y1 > (y + (subY / (double) AA_SAMPLING))) { //System.err.println(edge); // TODO: Eliminate the aligments. int x0 = (int) Math.min(Math.max(previous.xIntersection, minX), maxX); int x1 = (int) Math.min(Math.max(edge.xIntersection, minX), maxX); //System.err.println("minX: " + minX + ", x0: " + x0 + ", x1: " + x1 + ", maxX: " + maxX); // TODO: Pull out cast. alpha[x0 - (int) minX]++; alpha[x1 - (int) minX + 1]--; previous = edge; active = false; } } else { // TODO: Use integer arithmetics here. if (edge.y1 > (y + (subY / (double) AA_SAMPLING))) { //System.err.println(edge); previous = edge; active = true; } } } yindex++; } firstSubline = 0; // Render full scanline. //System.err.println("scanline: " + y); fillScanlineAA(alpha, (int) minX, (int) y, numScanlinePixels, pCtx); } if (paint instanceof Color && composite == AlphaComposite.SrcOver) rawSetForeground((Color) paint); pCtx.dispose(); }
int numScanlines = (int) Math.ceil(maxY) - (int) minY; int numScanlinePixels = (int) Math.ceil(maxX) - (int) minX + 1;
int numScanlines = (int) Math.ceil(icMaxY) - (int) icMinY; int numScanlinePixels = (int) Math.ceil(icMaxX) - (int) icMinX + 1;
private void fillShapeAntialias(ArrayList segs, double minX, double minY, double maxX, double maxY, Rectangle2D userBounds) { // This is an implementation of a polygon scanline conversion algorithm // described here: // http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/scan/ // The antialiasing is implemented using a sampling technique, we do // not scan whole lines but fractions of the line. Rectangle deviceBounds = new Rectangle((int) minX, (int) minY, (int) Math.ceil(maxX) - (int) minX, (int) Math.ceil(maxY) - (int) minY); PaintContext pCtx = paint.createContext(getColorModel(), deviceBounds, userBounds, transform, renderingHints); // This array will contain the oversampled transparency values for // each pixel in the scanline. int numScanlines = (int) Math.ceil(maxY) - (int) minY; int numScanlinePixels = (int) Math.ceil(maxX) - (int) minX + 1; if (alpha == null || alpha.length < (numScanlinePixels + 1)) alpha = new int[numScanlinePixels + 1]; int firstLine = (int) minY; //System.err.println("minY: " + minY); int firstSubline = (int) (Math.ceil((minY - Math.floor(minY)) * AA_SAMPLING)); double firstLineDouble = firstLine + firstSubline / (double) AA_SAMPLING; //System.err.println("firstSubline: " + firstSubline); // Create table of all edges. // The edge buckets, sorted and indexed by their Y values. //System.err.println("numScanlines: " + numScanlines); if (edgeTable == null || edgeTable.length < numScanlines * AA_SAMPLING + AA_SAMPLING) edgeTable = new ArrayList[numScanlines * AA_SAMPLING + AA_SAMPLING]; //System.err.println("firstLineDouble: " + firstLineDouble); for (Iterator i = segs.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); int yindex = (int) (Math.ceil((edge.y0 - firstLineDouble) * AA_SAMPLING)); //System.err.println("yindex: " + yindex + " for y0: " + edge.y0); // Initialize edge's slope and initial xIntersection. edge.slope = ((edge.x1 - edge.x0) / (edge.y1 - edge.y0)) / AA_SAMPLING; if (edge.y0 == edge.y1) // Horizontal edge. edge.xIntersection = Math.min(edge.x0, edge.x1); else { double alignedFirst = Math.ceil(edge.y0 * AA_SAMPLING) / AA_SAMPLING; edge.xIntersection = edge.x0 + (edge.slope * AA_SAMPLING) * (alignedFirst - edge.y0); } //System.err.println(edge); // FIXME: Sanity check should not be needed when clipping works. if (yindex >= 0 && yindex < edgeTable.length) { if (edgeTable[yindex] == null) // Create bucket when needed. edgeTable[yindex] = new ArrayList(); edgeTable[yindex].add(edge); // Add edge to the bucket of its line. } } // The activeEdges list contains all the edges of the current scanline // ordered by their intersection points with this scanline. ArrayList activeEdges = new ArrayList(); PolyEdgeComparator comparator = new PolyEdgeComparator(); // Scan all lines. int yindex = 0; //System.err.println("firstLine: " + firstLine + ", maxY: " + maxY + ", firstSubline: " + firstSubline); for (int y = firstLine; y <= maxY; y++) { for (int subY = firstSubline; subY < AA_SAMPLING; subY++) { //System.err.println("scanline: " + y + ", subScanline: " + subY); ArrayList bucket = edgeTable[yindex]; // Update all the x intersections in the current activeEdges table // and remove entries that are no longer in the scanline. for (Iterator i = activeEdges.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); // TODO: Do the following using integer arithmetics. if ((y + ((double) subY / (double) AA_SAMPLING)) > edge.y1) i.remove(); else { edge.xIntersection += edge.slope; //System.err.println("edge: " + edge); //edge.xIntersection = edge.x0 + edge.slope * (y - edge.y0); //System.err.println("edge.xIntersection: " + edge.xIntersection); } } if (bucket != null) { activeEdges.addAll(bucket); edgeTable[yindex].clear(); } // Sort current edges. We are using a bubble sort, because the order // of the intersections will not change in most situations. They // will only change, when edges intersect each other. int size = activeEdges.size(); if (size > 1) { for (int i = 1; i < size; i++) { PolyEdge e1 = (PolyEdge) activeEdges.get(i - 1); PolyEdge e2 = (PolyEdge) activeEdges.get(i); if (comparator.compare(e1, e2) > 0) { // Swap e2 with its left neighbor until it 'fits'. int j = i; do { activeEdges.set(j, e1); activeEdges.set(j - 1, e2); j--; if (j >= 1) e1 = (PolyEdge) activeEdges.get(j - 1); } while (j >= 1 && comparator.compare(e1, e2) > 0); } } } // Now draw all pixels inside the polygon. // This is the last edge that intersected the scanline. PolyEdge previous = null; // Gets initialized below. boolean active = false; //System.err.println("scanline: " + y + ", subscanline: " + subY); for (Iterator i = activeEdges.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); // Only fill scanline, if the current edge actually intersects // the scanline. There may be edges that lie completely // within the current scanline. //System.err.println("previous: " + previous); //System.err.println("edge: " + edge); if (active) { // TODO: Use integer arithmetics here. if (edge.y1 > (y + (subY / (double) AA_SAMPLING))) { //System.err.println(edge); // TODO: Eliminate the aligments. int x0 = (int) Math.min(Math.max(previous.xIntersection, minX), maxX); int x1 = (int) Math.min(Math.max(edge.xIntersection, minX), maxX); //System.err.println("minX: " + minX + ", x0: " + x0 + ", x1: " + x1 + ", maxX: " + maxX); // TODO: Pull out cast. alpha[x0 - (int) minX]++; alpha[x1 - (int) minX + 1]--; previous = edge; active = false; } } else { // TODO: Use integer arithmetics here. if (edge.y1 > (y + (subY / (double) AA_SAMPLING))) { //System.err.println(edge); previous = edge; active = true; } } } yindex++; } firstSubline = 0; // Render full scanline. //System.err.println("scanline: " + y); fillScanlineAA(alpha, (int) minX, (int) y, numScanlinePixels, pCtx); } if (paint instanceof Color && composite == AlphaComposite.SrcOver) rawSetForeground((Color) paint); pCtx.dispose(); }
int firstLine = (int) minY;
int firstLine = (int) icMinY;
private void fillShapeAntialias(ArrayList segs, double minX, double minY, double maxX, double maxY, Rectangle2D userBounds) { // This is an implementation of a polygon scanline conversion algorithm // described here: // http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/scan/ // The antialiasing is implemented using a sampling technique, we do // not scan whole lines but fractions of the line. Rectangle deviceBounds = new Rectangle((int) minX, (int) minY, (int) Math.ceil(maxX) - (int) minX, (int) Math.ceil(maxY) - (int) minY); PaintContext pCtx = paint.createContext(getColorModel(), deviceBounds, userBounds, transform, renderingHints); // This array will contain the oversampled transparency values for // each pixel in the scanline. int numScanlines = (int) Math.ceil(maxY) - (int) minY; int numScanlinePixels = (int) Math.ceil(maxX) - (int) minX + 1; if (alpha == null || alpha.length < (numScanlinePixels + 1)) alpha = new int[numScanlinePixels + 1]; int firstLine = (int) minY; //System.err.println("minY: " + minY); int firstSubline = (int) (Math.ceil((minY - Math.floor(minY)) * AA_SAMPLING)); double firstLineDouble = firstLine + firstSubline / (double) AA_SAMPLING; //System.err.println("firstSubline: " + firstSubline); // Create table of all edges. // The edge buckets, sorted and indexed by their Y values. //System.err.println("numScanlines: " + numScanlines); if (edgeTable == null || edgeTable.length < numScanlines * AA_SAMPLING + AA_SAMPLING) edgeTable = new ArrayList[numScanlines * AA_SAMPLING + AA_SAMPLING]; //System.err.println("firstLineDouble: " + firstLineDouble); for (Iterator i = segs.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); int yindex = (int) (Math.ceil((edge.y0 - firstLineDouble) * AA_SAMPLING)); //System.err.println("yindex: " + yindex + " for y0: " + edge.y0); // Initialize edge's slope and initial xIntersection. edge.slope = ((edge.x1 - edge.x0) / (edge.y1 - edge.y0)) / AA_SAMPLING; if (edge.y0 == edge.y1) // Horizontal edge. edge.xIntersection = Math.min(edge.x0, edge.x1); else { double alignedFirst = Math.ceil(edge.y0 * AA_SAMPLING) / AA_SAMPLING; edge.xIntersection = edge.x0 + (edge.slope * AA_SAMPLING) * (alignedFirst - edge.y0); } //System.err.println(edge); // FIXME: Sanity check should not be needed when clipping works. if (yindex >= 0 && yindex < edgeTable.length) { if (edgeTable[yindex] == null) // Create bucket when needed. edgeTable[yindex] = new ArrayList(); edgeTable[yindex].add(edge); // Add edge to the bucket of its line. } } // The activeEdges list contains all the edges of the current scanline // ordered by their intersection points with this scanline. ArrayList activeEdges = new ArrayList(); PolyEdgeComparator comparator = new PolyEdgeComparator(); // Scan all lines. int yindex = 0; //System.err.println("firstLine: " + firstLine + ", maxY: " + maxY + ", firstSubline: " + firstSubline); for (int y = firstLine; y <= maxY; y++) { for (int subY = firstSubline; subY < AA_SAMPLING; subY++) { //System.err.println("scanline: " + y + ", subScanline: " + subY); ArrayList bucket = edgeTable[yindex]; // Update all the x intersections in the current activeEdges table // and remove entries that are no longer in the scanline. for (Iterator i = activeEdges.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); // TODO: Do the following using integer arithmetics. if ((y + ((double) subY / (double) AA_SAMPLING)) > edge.y1) i.remove(); else { edge.xIntersection += edge.slope; //System.err.println("edge: " + edge); //edge.xIntersection = edge.x0 + edge.slope * (y - edge.y0); //System.err.println("edge.xIntersection: " + edge.xIntersection); } } if (bucket != null) { activeEdges.addAll(bucket); edgeTable[yindex].clear(); } // Sort current edges. We are using a bubble sort, because the order // of the intersections will not change in most situations. They // will only change, when edges intersect each other. int size = activeEdges.size(); if (size > 1) { for (int i = 1; i < size; i++) { PolyEdge e1 = (PolyEdge) activeEdges.get(i - 1); PolyEdge e2 = (PolyEdge) activeEdges.get(i); if (comparator.compare(e1, e2) > 0) { // Swap e2 with its left neighbor until it 'fits'. int j = i; do { activeEdges.set(j, e1); activeEdges.set(j - 1, e2); j--; if (j >= 1) e1 = (PolyEdge) activeEdges.get(j - 1); } while (j >= 1 && comparator.compare(e1, e2) > 0); } } } // Now draw all pixels inside the polygon. // This is the last edge that intersected the scanline. PolyEdge previous = null; // Gets initialized below. boolean active = false; //System.err.println("scanline: " + y + ", subscanline: " + subY); for (Iterator i = activeEdges.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); // Only fill scanline, if the current edge actually intersects // the scanline. There may be edges that lie completely // within the current scanline. //System.err.println("previous: " + previous); //System.err.println("edge: " + edge); if (active) { // TODO: Use integer arithmetics here. if (edge.y1 > (y + (subY / (double) AA_SAMPLING))) { //System.err.println(edge); // TODO: Eliminate the aligments. int x0 = (int) Math.min(Math.max(previous.xIntersection, minX), maxX); int x1 = (int) Math.min(Math.max(edge.xIntersection, minX), maxX); //System.err.println("minX: " + minX + ", x0: " + x0 + ", x1: " + x1 + ", maxX: " + maxX); // TODO: Pull out cast. alpha[x0 - (int) minX]++; alpha[x1 - (int) minX + 1]--; previous = edge; active = false; } } else { // TODO: Use integer arithmetics here. if (edge.y1 > (y + (subY / (double) AA_SAMPLING))) { //System.err.println(edge); previous = edge; active = true; } } } yindex++; } firstSubline = 0; // Render full scanline. //System.err.println("scanline: " + y); fillScanlineAA(alpha, (int) minX, (int) y, numScanlinePixels, pCtx); } if (paint instanceof Color && composite == AlphaComposite.SrcOver) rawSetForeground((Color) paint); pCtx.dispose(); }
int firstSubline = (int) (Math.ceil((minY - Math.floor(minY)) * AA_SAMPLING));
int firstSubline = (int) (Math.ceil((icMinY - Math.floor(icMinY)) * AA_SAMPLING));
private void fillShapeAntialias(ArrayList segs, double minX, double minY, double maxX, double maxY, Rectangle2D userBounds) { // This is an implementation of a polygon scanline conversion algorithm // described here: // http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/scan/ // The antialiasing is implemented using a sampling technique, we do // not scan whole lines but fractions of the line. Rectangle deviceBounds = new Rectangle((int) minX, (int) minY, (int) Math.ceil(maxX) - (int) minX, (int) Math.ceil(maxY) - (int) minY); PaintContext pCtx = paint.createContext(getColorModel(), deviceBounds, userBounds, transform, renderingHints); // This array will contain the oversampled transparency values for // each pixel in the scanline. int numScanlines = (int) Math.ceil(maxY) - (int) minY; int numScanlinePixels = (int) Math.ceil(maxX) - (int) minX + 1; if (alpha == null || alpha.length < (numScanlinePixels + 1)) alpha = new int[numScanlinePixels + 1]; int firstLine = (int) minY; //System.err.println("minY: " + minY); int firstSubline = (int) (Math.ceil((minY - Math.floor(minY)) * AA_SAMPLING)); double firstLineDouble = firstLine + firstSubline / (double) AA_SAMPLING; //System.err.println("firstSubline: " + firstSubline); // Create table of all edges. // The edge buckets, sorted and indexed by their Y values. //System.err.println("numScanlines: " + numScanlines); if (edgeTable == null || edgeTable.length < numScanlines * AA_SAMPLING + AA_SAMPLING) edgeTable = new ArrayList[numScanlines * AA_SAMPLING + AA_SAMPLING]; //System.err.println("firstLineDouble: " + firstLineDouble); for (Iterator i = segs.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); int yindex = (int) (Math.ceil((edge.y0 - firstLineDouble) * AA_SAMPLING)); //System.err.println("yindex: " + yindex + " for y0: " + edge.y0); // Initialize edge's slope and initial xIntersection. edge.slope = ((edge.x1 - edge.x0) / (edge.y1 - edge.y0)) / AA_SAMPLING; if (edge.y0 == edge.y1) // Horizontal edge. edge.xIntersection = Math.min(edge.x0, edge.x1); else { double alignedFirst = Math.ceil(edge.y0 * AA_SAMPLING) / AA_SAMPLING; edge.xIntersection = edge.x0 + (edge.slope * AA_SAMPLING) * (alignedFirst - edge.y0); } //System.err.println(edge); // FIXME: Sanity check should not be needed when clipping works. if (yindex >= 0 && yindex < edgeTable.length) { if (edgeTable[yindex] == null) // Create bucket when needed. edgeTable[yindex] = new ArrayList(); edgeTable[yindex].add(edge); // Add edge to the bucket of its line. } } // The activeEdges list contains all the edges of the current scanline // ordered by their intersection points with this scanline. ArrayList activeEdges = new ArrayList(); PolyEdgeComparator comparator = new PolyEdgeComparator(); // Scan all lines. int yindex = 0; //System.err.println("firstLine: " + firstLine + ", maxY: " + maxY + ", firstSubline: " + firstSubline); for (int y = firstLine; y <= maxY; y++) { for (int subY = firstSubline; subY < AA_SAMPLING; subY++) { //System.err.println("scanline: " + y + ", subScanline: " + subY); ArrayList bucket = edgeTable[yindex]; // Update all the x intersections in the current activeEdges table // and remove entries that are no longer in the scanline. for (Iterator i = activeEdges.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); // TODO: Do the following using integer arithmetics. if ((y + ((double) subY / (double) AA_SAMPLING)) > edge.y1) i.remove(); else { edge.xIntersection += edge.slope; //System.err.println("edge: " + edge); //edge.xIntersection = edge.x0 + edge.slope * (y - edge.y0); //System.err.println("edge.xIntersection: " + edge.xIntersection); } } if (bucket != null) { activeEdges.addAll(bucket); edgeTable[yindex].clear(); } // Sort current edges. We are using a bubble sort, because the order // of the intersections will not change in most situations. They // will only change, when edges intersect each other. int size = activeEdges.size(); if (size > 1) { for (int i = 1; i < size; i++) { PolyEdge e1 = (PolyEdge) activeEdges.get(i - 1); PolyEdge e2 = (PolyEdge) activeEdges.get(i); if (comparator.compare(e1, e2) > 0) { // Swap e2 with its left neighbor until it 'fits'. int j = i; do { activeEdges.set(j, e1); activeEdges.set(j - 1, e2); j--; if (j >= 1) e1 = (PolyEdge) activeEdges.get(j - 1); } while (j >= 1 && comparator.compare(e1, e2) > 0); } } } // Now draw all pixels inside the polygon. // This is the last edge that intersected the scanline. PolyEdge previous = null; // Gets initialized below. boolean active = false; //System.err.println("scanline: " + y + ", subscanline: " + subY); for (Iterator i = activeEdges.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); // Only fill scanline, if the current edge actually intersects // the scanline. There may be edges that lie completely // within the current scanline. //System.err.println("previous: " + previous); //System.err.println("edge: " + edge); if (active) { // TODO: Use integer arithmetics here. if (edge.y1 > (y + (subY / (double) AA_SAMPLING))) { //System.err.println(edge); // TODO: Eliminate the aligments. int x0 = (int) Math.min(Math.max(previous.xIntersection, minX), maxX); int x1 = (int) Math.min(Math.max(edge.xIntersection, minX), maxX); //System.err.println("minX: " + minX + ", x0: " + x0 + ", x1: " + x1 + ", maxX: " + maxX); // TODO: Pull out cast. alpha[x0 - (int) minX]++; alpha[x1 - (int) minX + 1]--; previous = edge; active = false; } } else { // TODO: Use integer arithmetics here. if (edge.y1 > (y + (subY / (double) AA_SAMPLING))) { //System.err.println(edge); previous = edge; active = true; } } } yindex++; } firstSubline = 0; // Render full scanline. //System.err.println("scanline: " + y); fillScanlineAA(alpha, (int) minX, (int) y, numScanlinePixels, pCtx); } if (paint instanceof Color && composite == AlphaComposite.SrcOver) rawSetForeground((Color) paint); pCtx.dispose(); }
for (int y = firstLine; y <= maxY; y++)
for (int y = firstLine; y <= icMaxY; y++)
private void fillShapeAntialias(ArrayList segs, double minX, double minY, double maxX, double maxY, Rectangle2D userBounds) { // This is an implementation of a polygon scanline conversion algorithm // described here: // http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/scan/ // The antialiasing is implemented using a sampling technique, we do // not scan whole lines but fractions of the line. Rectangle deviceBounds = new Rectangle((int) minX, (int) minY, (int) Math.ceil(maxX) - (int) minX, (int) Math.ceil(maxY) - (int) minY); PaintContext pCtx = paint.createContext(getColorModel(), deviceBounds, userBounds, transform, renderingHints); // This array will contain the oversampled transparency values for // each pixel in the scanline. int numScanlines = (int) Math.ceil(maxY) - (int) minY; int numScanlinePixels = (int) Math.ceil(maxX) - (int) minX + 1; if (alpha == null || alpha.length < (numScanlinePixels + 1)) alpha = new int[numScanlinePixels + 1]; int firstLine = (int) minY; //System.err.println("minY: " + minY); int firstSubline = (int) (Math.ceil((minY - Math.floor(minY)) * AA_SAMPLING)); double firstLineDouble = firstLine + firstSubline / (double) AA_SAMPLING; //System.err.println("firstSubline: " + firstSubline); // Create table of all edges. // The edge buckets, sorted and indexed by their Y values. //System.err.println("numScanlines: " + numScanlines); if (edgeTable == null || edgeTable.length < numScanlines * AA_SAMPLING + AA_SAMPLING) edgeTable = new ArrayList[numScanlines * AA_SAMPLING + AA_SAMPLING]; //System.err.println("firstLineDouble: " + firstLineDouble); for (Iterator i = segs.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); int yindex = (int) (Math.ceil((edge.y0 - firstLineDouble) * AA_SAMPLING)); //System.err.println("yindex: " + yindex + " for y0: " + edge.y0); // Initialize edge's slope and initial xIntersection. edge.slope = ((edge.x1 - edge.x0) / (edge.y1 - edge.y0)) / AA_SAMPLING; if (edge.y0 == edge.y1) // Horizontal edge. edge.xIntersection = Math.min(edge.x0, edge.x1); else { double alignedFirst = Math.ceil(edge.y0 * AA_SAMPLING) / AA_SAMPLING; edge.xIntersection = edge.x0 + (edge.slope * AA_SAMPLING) * (alignedFirst - edge.y0); } //System.err.println(edge); // FIXME: Sanity check should not be needed when clipping works. if (yindex >= 0 && yindex < edgeTable.length) { if (edgeTable[yindex] == null) // Create bucket when needed. edgeTable[yindex] = new ArrayList(); edgeTable[yindex].add(edge); // Add edge to the bucket of its line. } } // The activeEdges list contains all the edges of the current scanline // ordered by their intersection points with this scanline. ArrayList activeEdges = new ArrayList(); PolyEdgeComparator comparator = new PolyEdgeComparator(); // Scan all lines. int yindex = 0; //System.err.println("firstLine: " + firstLine + ", maxY: " + maxY + ", firstSubline: " + firstSubline); for (int y = firstLine; y <= maxY; y++) { for (int subY = firstSubline; subY < AA_SAMPLING; subY++) { //System.err.println("scanline: " + y + ", subScanline: " + subY); ArrayList bucket = edgeTable[yindex]; // Update all the x intersections in the current activeEdges table // and remove entries that are no longer in the scanline. for (Iterator i = activeEdges.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); // TODO: Do the following using integer arithmetics. if ((y + ((double) subY / (double) AA_SAMPLING)) > edge.y1) i.remove(); else { edge.xIntersection += edge.slope; //System.err.println("edge: " + edge); //edge.xIntersection = edge.x0 + edge.slope * (y - edge.y0); //System.err.println("edge.xIntersection: " + edge.xIntersection); } } if (bucket != null) { activeEdges.addAll(bucket); edgeTable[yindex].clear(); } // Sort current edges. We are using a bubble sort, because the order // of the intersections will not change in most situations. They // will only change, when edges intersect each other. int size = activeEdges.size(); if (size > 1) { for (int i = 1; i < size; i++) { PolyEdge e1 = (PolyEdge) activeEdges.get(i - 1); PolyEdge e2 = (PolyEdge) activeEdges.get(i); if (comparator.compare(e1, e2) > 0) { // Swap e2 with its left neighbor until it 'fits'. int j = i; do { activeEdges.set(j, e1); activeEdges.set(j - 1, e2); j--; if (j >= 1) e1 = (PolyEdge) activeEdges.get(j - 1); } while (j >= 1 && comparator.compare(e1, e2) > 0); } } } // Now draw all pixels inside the polygon. // This is the last edge that intersected the scanline. PolyEdge previous = null; // Gets initialized below. boolean active = false; //System.err.println("scanline: " + y + ", subscanline: " + subY); for (Iterator i = activeEdges.iterator(); i.hasNext();) { PolyEdge edge = (PolyEdge) i.next(); // Only fill scanline, if the current edge actually intersects // the scanline. There may be edges that lie completely // within the current scanline. //System.err.println("previous: " + previous); //System.err.println("edge: " + edge); if (active) { // TODO: Use integer arithmetics here. if (edge.y1 > (y + (subY / (double) AA_SAMPLING))) { //System.err.println(edge); // TODO: Eliminate the aligments. int x0 = (int) Math.min(Math.max(previous.xIntersection, minX), maxX); int x1 = (int) Math.min(Math.max(edge.xIntersection, minX), maxX); //System.err.println("minX: " + minX + ", x0: " + x0 + ", x1: " + x1 + ", maxX: " + maxX); // TODO: Pull out cast. alpha[x0 - (int) minX]++; alpha[x1 - (int) minX + 1]--; previous = edge; active = false; } } else { // TODO: Use integer arithmetics here. if (edge.y1 > (y + (subY / (double) AA_SAMPLING))) { //System.err.println(edge); previous = edge; active = true; } } } yindex++; } firstSubline = 0; // Render full scanline. //System.err.println("scanline: " + y); fillScanlineAA(alpha, (int) minX, (int) y, numScanlinePixels, pCtx); } if (paint instanceof Color && composite == AlphaComposite.SrcOver) rawSetForeground((Color) paint); pCtx.dispose(); }