?? drawingattributes.java
字號(hào):
clone.fillPaint = fillPaint; clone.mattingPaint = mattingPaint; clone.fillPattern = fillPattern; clone.setStroke(stroke); clone.baseScale = baseScale; clone.matted = matted; } public boolean equals(DrawingAttributes da) { return (da.linePaint == linePaint && // da.textPaint == textPaint && da.selectPaint == selectPaint && da.fillPaint == fillPaint && da.mattingPaint == mattingPaint && da.fillPattern == fillPattern && da.stroke == stroke && da.baseScale == baseScale && da.matted == matted); } /** * If you want to get a DEFAULT DrawingAttributes object that you * may modify, get your own copy. */ public static DrawingAttributes getDefaultClone() { return (DrawingAttributes) DEFAULT.clone(); } /** * Call setProperties without a prefix for the properties. * * @param props the Properties to look in. * @deprecated use setProperties(props). */ public void init(Properties props) { setProperties(null, props); } /** * Look at the Properties, and fill in the drawing attributes * based in it's contents. If a property is not in the properties, * it's set to its default setting. * * @param prefix the prefix marker to use for a property, like * prefix.propertyName. The period is added in this * function. * @param props the Properties to look in. * @deprecated use setProperties(prefix, props). */ public void init(String prefix, Properties props) { setProperties(prefix, props); } /** * Set the Stroke to use for the edge of a graphic. */ public void setStroke(Stroke stroke) { Stroke oldStroke = this.stroke; this.stroke = stroke; // We don't want to call getBasicStrokeEditor, that creates // the editor if it doesn't exist, which may be problematic // for cases where there is no Graphics Display. if (stroke instanceof BasicStroke && bse != null) { bse.setBasicStroke((BasicStroke) stroke); // This requires that the JRE has a display, which may be // unnecessary in some situations where the editor is // never used. // BasicStrokeEditorMenu tmpbse = getBasicStrokeEditor(); // if (tmpbse != null) { // tmpbse.setBasicStroke((BasicStroke) stroke); // } } if (propertyChangeSupport != null) { propertyChangeSupport.firePropertyChange("stroke", oldStroke, stroke); } } /** * Get the Stroke used for the lines of a graphic. */ public Stroke getStroke() { return stroke; } /** * Get the Stroke object, scaled for comparison to the base scale. * If the base scale equals NONE, it's the same as getStroke(). * * @param scale scale to compare to the base scale. */ public Stroke getStrokeForScale(float scale) { if (baseScale != NONE && stroke instanceof BasicStroke) { BasicStroke bs = (BasicStroke) stroke; float lineWidth = bs.getLineWidth(); float[] dash = bs.getDashArray(); float scaleFactor = scale / baseScale; int endCaps = bs.getEndCap(); int lineJoins = bs.getLineJoin(); float miterLimit = bs.getMiterLimit(); lineWidth *= scaleFactor; for (int i = 0; i < dash.length; i++) { dash[i] *= scaleFactor; } return new BasicStroke(lineWidth, endCaps, lineJoins, miterLimit, dash, bs.getDashPhase()); } return stroke; } /** * Get the Paint for these attributes, and scale it for the scale * compaired to the base scale set if the fill Paint is a * TexturePattern. If the base scale equals NONE, or if the Paint * is not a TexturePaint, it's the same as getFillPaint(). * * @param scale scale to compare to the base scale. * @return a Paint object to use for the fill, scaled if * necessary. */ public Paint getFillPaintForScale(float scale) { if (fillPattern != null) { if (baseScale != NONE) { BufferedImage bi = fillPattern.getImage(); float scaleFactor = scale / baseScale; Image image = bi.getScaledInstance((int) (bi.getWidth() * scaleFactor), (int) (bi.getHeight() * scaleFactor), Image.SCALE_SMOOTH); try { bi = BufferedImageHelper.getBufferedImage(image, 0, 0, -1, -1); return new TexturePaint(bi, new Rectangle(0, 0, bi.getWidth(), bi.getHeight())); } catch (InterruptedException ie) { Debug.error("DrawingAttributes: Interrupted Exception scaling texture paint"); } } return fillPattern; } else { return fillPaint; } } /** * Set the edge paint for the graphics created for the coverage * type. * * @param lPaint the paint. */ public void setLinePaint(Paint lPaint) { if (lPaint == linePaint) return; Paint oldPaint = linePaint; linePaint = lPaint; if (lineColorButton != null) { lineColorButton.setIcon(getIconForPaint(linePaint, false)); } if (mattedCheckBox != null) { mattedCheckBox.setIcon(getMattedIcon()); } propertyChangeSupport.firePropertyChange("linePaint", oldPaint, linePaint); } /** * Get the line paint for the graphics created for the coverage * type. * * @return the line paint to use for the edges. */ public Paint getLinePaint() { return linePaint; } /** * Set the selected edge paint for the graphics created for the * coverage type. * * @param sPaint the paint. */ public void setSelectPaint(Paint sPaint) { if (sPaint == selectPaint) return; Paint oldPaint = selectPaint; selectPaint = sPaint; if (selectColorButton != null) { selectColorButton.setIcon(getIconForPaint(selectPaint, false)); } propertyChangeSupport.firePropertyChange("selectPaint", oldPaint, selectPaint); } /** * Get the line paint for the graphics created for the coverage * type. * * @return the select line paint to use for the edges. */ public Paint getSelectPaint() { return selectPaint; } /** * Set the fill paint for the graphics created for the coverage * type. * * @param fPaint the paint. */ public void setFillPaint(Paint fPaint) { if (fPaint == fillPaint) return; Paint oldPaint = fillPaint; fillPaint = fPaint; if (fillColorButton != null) { fillColorButton.setIcon(getIconForPaint(fillPaint, true)); } propertyChangeSupport.firePropertyChange("fillPaint", oldPaint, fillPaint); } /** * Get the fill paint for the graphics created for the coverage * type. This used to return the fillPattern if it was defined. * Now, it always returns the fillPaint. * * @return the fill paint to use for the areas. */ public Paint getFillPaint() { return fillPaint; } /** * Set the matting paint for the graphics created for the coverage * type. The matting paint is the paint used for the matting line * painted around the edge, two pixels wider than the edge line * width. Black by default, only painted when the matting variable * is set to true. * * @param mPaint the paint. */ public void setMattingPaint(Paint mPaint) { if (mPaint == mattingPaint) return; Paint oldPaint = mattingPaint; mattingPaint = mPaint; if (mattingColorButton != null) { mattingColorButton.setIcon(getMattingIconForPaint()); } if (mattedCheckBox != null) { mattedCheckBox.setIcon(getMattedIcon()); } propertyChangeSupport.firePropertyChange("mattingPaint", oldPaint, mattingPaint); } /** * Get the matting paint for the OMGraphics * * @return the matting paint to use for the areas. */ public Paint getMattingPaint() { return mattingPaint; } /** * Set the fill pattern TexturePaint to be used as the fill color. * If not null, the fillPattern will be returned from * getFillPaint() instead of fillPaint. * * @param fPattern the TexturePaint to set. */ public void setFillPattern(TexturePaint fPattern) { Paint oldPattern = fPattern; fillPattern = fPattern; if (fillColorButton != null) { // GUI doesn't handle fill patterns yet. } propertyChangeSupport.firePropertyChange("fillPattern", oldPattern, fillPattern); } /** * Get the TexturePaint set as the fill pattern. * * @return TexturePaint. */ public TexturePaint getFillPattern() { return fillPattern; } /** * Set the base scale to use for the texture paint and stroke. If * this is set to a negative number, then no scaling of the paint * or stroke will be performed. * * @param bScale the base scale to use - 1:bScale. */ public void setBaseScale(float bScale) { if (bScale > 0) { baseScale = bScale; } else { baseScale = NONE; } } /** * Get the base scale that the texture paint and dashes are set * for. If the texture paint and stroke are asked for with a * scale, those values will be adjusted accordingly. * * @return base scale for paint and stroke. */ public float getBaseScale() { return baseScale; } /** * Return whether the OMGraphic has matting around the edge. */ public boolean isMatted() { return matted; } /** * Set whether the OMGraphic should have matting around the edge. */ public void setMatted(boolean set) { boolean oldMatted = matted; matted = set; if (mattedCheckBox != null) { mattedCheckBox.setSelected(matted); } propertyChangeSupport.firePropertyChange("matted", oldMatted, matted); }
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -