⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svgvisualresourcevectorcirclechooserattributewidget.java

📁 完全基于java开发的svg矢量绘图工具
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    			    			//adds the vector chooser panel    			widgetPanel.add(vectChooserPanel, BorderLayout.CENTER);                //the listener to the combo box                final ActionListener comboListener=new ActionListener(){                                        public void actionPerformed(ActionEvent evt) {                                                String val="";                                                if(combo.getSelectedItem()!=null){                                                        val=((SVGComboItem)combo.getSelectedItem()).getValue();                        }                        //modifies the widgetValue of the property item                        if(val!=null && ! val.equals("")){                                                        //saving the values for the current state                            Point2D.Double point1=new Point2D.Double(0, 0), point2=new Point2D.Double(0, 0);                            double radius=0;                                                        String 	px1Str=px1Txt.getText(),                             			py1Str=py1Txt.getText(),                            			px2Str=px2Txt.getText(),                            			py2Str=py2Txt.getText(),                            			radiusStr=radiusTxt.getText();                                                        if(fvectChValues.isDefaultGradientUnits()){                                                                px1Str=px1Str.concat("%");                                py1Str=py1Str.concat("%");                                px2Str=px2Str.concat("%");                                py2Str=py2Str.concat("%");                                radiusStr=py2Str.concat("%");                            }                            point1.x=svgEditor.getSVGToolkit().getDoubleValue(px1Str, fvectChValues.isDefaultGradientUnits());                            point1.y=svgEditor.getSVGToolkit().getDoubleValue(py1Str, fvectChValues.isDefaultGradientUnits());                            point2.x=svgEditor.getSVGToolkit().getDoubleValue(px2Str, fvectChValues.isDefaultGradientUnits());                            point2.y=svgEditor.getSVGToolkit().getDoubleValue(py2Str, fvectChValues.isDefaultGradientUnits());                            radius=svgEditor.getSVGToolkit().getDoubleValue(radiusStr, fvectChValues.isDefaultGradientUnits());                            if(fvectChValues.isDefaultGradientUnits()){                                                                fvectChValues.setDefaultPoint1(point1);                                fvectChValues.setDefaultPoint2(point2);                                fvectChValues.setDefaultRadius(radius);                            }else{                                                                fvectChValues.setOtherPoint1(point1);                                fvectChValues.setOtherPoint2(point2);                                fvectChValues.setOtherRadius(radius);                            }                                                        //setting the new attribute value                            fgradientUnitsAtt.setValue(val);                            fvectChValues.setDefaultGradientUnits(! fgradientUnitsAtt.getValue().equals(gradientUnitsOther));                                                        //sets the label for the units                            String unitSign=fvectChValues.getUnitSign();                            px1UnitLbl.setText(unitSign);                            py1UnitLbl.setText(unitSign);                            px2UnitLbl.setText(unitSign);                            py2UnitLbl.setText(unitSign);                            radiusUnitLbl.setText(unitSign);                                                        if(fvectChValues.isDefaultGradientUnits()){                                px1Str=format.format(fvectChValues.getDefaultPoint1().x);                                py1Str=format.format(fvectChValues.getDefaultPoint1().y);                                px2Str=format.format(fvectChValues.getDefaultPoint2().x);                                py2Str=format.format(fvectChValues.getDefaultPoint2().y);                                radiusStr=format.format(fvectChValues.getDefaultRadius());                                                                px1Txt.setText(px1Str);                                py1Txt.setText(py1Str);                                px2Txt.setText(px2Str);                                py2Txt.setText(py2Str);                                radiusTxt.setText(radiusStr);                                                                px1Str=px1Str.concat("%");                                py1Str=py1Str.concat("%");                                px2Str=px2Str.concat("%");                                py2Str=py2Str.concat("%");                                radiusStr=radiusStr.concat("%");                                                                //sets the color for the labels                                px1Lbl.setForeground(fvectChValues.getPoint1Color());                                py1Lbl.setForeground(fvectChValues.getPoint1Color());                                px2Lbl.setForeground(fvectChValues.getPoint2Color());                                py2Lbl.setForeground(fvectChValues.getPoint2Color());                                radiusLbl.setForeground(fvectChValues.getRadiusColor());                                //enables the vector chooser panel                                items.setEnabled(true);                                vectorPanel.setVisible(true);                                                                //adds the listener to the vector panel                                vectorPanel.addMouseListener(vectorPanelListener);                                vectorPanel.addMouseMotionListener(vectorPanelListener);                            }else{                                                                px1Str=format.format(fvectChValues.getOtherPoint1().x);                                py1Str=format.format(fvectChValues.getOtherPoint1().y);                                px2Str=format.format(fvectChValues.getOtherPoint2().x);                                py2Str=format.format(fvectChValues.getOtherPoint2().y);                                radiusStr=format.format(fvectChValues.getOtherRadius());                                px1Txt.setText(px1Str);                                py1Txt.setText(py1Str);                                px2Txt.setText(px2Str);                                py2Txt.setText(py2Str);                                radiusTxt.setText(radiusStr);                                                                //sets the color for the labels                                px1Lbl.setForeground(Color.black);                                py1Lbl.setForeground(Color.black);                                px2Lbl.setForeground(Color.black);                                py2Lbl.setForeground(Color.black);                                radiusLbl.setForeground(Color.black);                                                                //disables the vector chooser panel                                items.setEnabled(false);                                vectorPanel.setVisible(false);                                                                //removes the listener to the vector panel                                vectorPanel.removeMouseListener(vectorPanelListener);                                vectorPanel.removeMouseMotionListener(vectorPanelListener);                            }                                                        //setting the value of the attributes                            fpx1Att.setValue(px1Str);                            fpy1Att.setValue(py1Str);                            fpx2Att.setValue(px2Str);                            fpy2Att.setValue(py2Str);                                                        if(fradiusAtt!=null){                                                                fradiusAtt.setValue(radiusStr);                            }                        }                    }                };                                //adds a listener to the combo box                combo.addActionListener(comboListener);                                component=widgetPanel;    			                disposer=new Runnable(){	                public void run() {                        //removes the mouse listener                        vectorPanel.removeMouseListener(vectorPanelListener);                        vectorPanel.removeMouseMotionListener(vectorPanelListener);                                                //adds the listener to the textfields                        px1Txt.removeCaretListener(textfieldsListener);                        py1Txt.removeCaretListener(textfieldsListener);                        px2Txt.removeCaretListener(textfieldsListener);                        py2Txt.removeCaretListener(textfieldsListener);                        radiusTxt.removeCaretListener(textfieldsListener);                                                //removes the listener from the combo box                        combo.removeActionListener(comboListener);                                                itmList.clear();                        resourceObjectAttribute=null;	                }                 };            }        }    }        /**     * the interface used to listens to the mouse events on a vector panel     *      * @author Jordi SUC     *     */    protected interface SVGVectorCirclePanelListener extends MouseListener, MouseMotionListener{                /**         * refreshes the display of the vector in the panel         */        public void refresh();    }        /**     * the class used to store information for the vector or circle chooser     *      * @author Jordi SUC     */    protected class SVGVectorCircleChooserValues{                /**         * the colors          */        private final Color point1Color=Color.blue;        private final Color point2Color=new Color(0, 175, 0);        private final Color radiusColor=Color.red;                /**         * the default points         */        private Point2D.Double defaultPoint1=null, defaultPoint2=null;                /**         * the other points         */        private Point2D.Double otherPoint1=null, otherPoint2=null;                /**         * the radius of the circle         */        private double defaultRadius=0, otherRadius=0;                /**         * the boolean telling if the default units are used or not         */        private boolean isDefaultGradientUnits=true;                /**         * the boolean telling if the vector chooser is used         */        private boolean isVectorChooser=true;                /**         * the constructor of the class         * @param defaultPoint1 the default point1         * @param defaultPoint2 the default point2         * @param defaultRadius the default radius         * @param otherPoint1 the other point1         * @param otherPoint2 the other point2         * @param otherRadius the other radius         * @param isDefaultGradientUnits the boolean telling if the default units are used or not         * @param isVectorChooser the boolean telling if the vector chooser is used         */        protected SVGVectorCircleChooserValues(	Point2D.Double defaultPoint1, Point2D.Double defaultPoint2, double defaultRadius,                 															Point2D.Double otherPoint1, Point2D.Double otherPoint2, double otherRadius,                 															boolean isDefaultGradientUnits, boolean isVectorChooser){                        this.defaultPoint1=defaultPoint1;            this.defaultPoint2=defaultPoint2;            this.defaultRadius=defaultRadius;            this.otherPoint1=otherPoint1;            this.otherPoint2=otherPoint2;            this.otherRadius=otherRadius;            this.isDefaultGradientUnits=isDefaultGradientUnits;            this.isVectorChooser=isVectorChooser;        }                /**         * @return a unit sign         */        protected String getUnitSign(){                        String unitSign="";                        if(isDefaultGradientUnits()){                                unitSign="%";                            }else{                               unitSign="px";            }                        return unitSign;        }        protected Color getPoint1Color() {            return point1Color;        }                protected Color getPoint2Color() {            return point2Color;        }                protected Color getRadiusColor() {            return radiusColor;        }                protected Point2D.Double getDefaultPoint1() {            return defaultPoint1;        }                protected void setDefaultPoint1(Point2D.Double defaultPoint1) {            this.defaultPoint1 = defaultPoint1;        }                protected Point2D.Double getDefaultPoint2() {            return defaultPoint2;        }        protected void setDefaultPoint2(Point2D.Double defaultPoint2) {            this.defaultPoint2 = defaultPoint2;        }        protected double getDefaultRadius() {            return defaultRadius;        }                protected void setDefaultRadius(double defaultRadius) {            this.defaultRadius = defaultRadius;        }                protected boolean isDefaultGradientUnits() {            return isDefaultGradientUnits;        }                protected void setDefaultGradientUnits(boolean isDefaultGradientUnits) {            this.isDefaultGradientUnits = isDefaultGradientUnits;        }                protected Point2D.Double getOtherPoint1() {            return otherPoint1;        }                protected void setOtherPoint1(Point2D.Double otherPoint1) {            this.otherPoint1 = otherPoint1;        }                protected Point2D.Double getOtherPoint2() {            return otherPoint2;        }                protected void setOtherPoint2(Point2D.Double otherPoint2) {            this.otherPoint2 = otherPoint2;        }        protected double getOtherRadius() {            return otherRadius;        }                protected void setOtherRadius(double otherRadius) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -