Package DisplayProject.controls

Source Code of DisplayProject.controls.Point$qq_Resolver

/*
Copyright (c) 2003-2008 ITerative Consulting Pty Ltd. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

o Redistributions of source code must retain the above copyright notice, this list of conditions and
the following disclaimer.
 
o Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.
   
o This jcTOOL Helper Class software, whether in binary or source form may not be used within,
or to derive, any other product without the specific prior written permission of the copyright holder

 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


*/
package DisplayProject.controls;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;

import DisplayProject.Constants;
import DisplayProject.UIutils;
import DisplayProject.actions.Parent;
import DisplayProject.actions.WidgetState;
import Framework.CloneHelper;
/**
* The Point class defines points, which can be displayed not only as single points, but also as graphic symbols, such as stars, circles, and squares.
*
*/
public class Point extends Figure {

    private static final long serialVersionUID = 1595314406209986185L;
    protected String Name = "";
    protected int Symbol = Constants.W_DEFAULT;
    public static class qq_Resolver {
        public static final int cFILLCOLOR_PENCOLOR = 1;
        public static final int cPENCOLOR_FILLCOLOR = 2;
        public static final int cSYMBOL = 6;
        public static final int cSYMBOL_X_Y = 3;
        public static final int cAPPDATA_PARENT_STATE_SYMBOL_X_Y = 4;
        public static final int cX_Y = 5;
    }

    public Point(Object appData, Container parent, int state, int symbol, int x, int y, int resolver) {
        this(x, y, Point.qq_Resolver.cX_Y);
        this.putClientProperty("qq_AppData", appData);
        this.setSymbol(symbol);
        Parent.set(this, parent);
        WidgetState.set(this, state);
    }

    public Point() {
        super();
        setOpaque(false);
        setFocusable(false);
      // TF:15/12/2009:DET-141:Set this up to allow inheriting of popup menu
      this.setInheritsPopupMenu(true);
    }

    public Point( int param1, int param2, int resolver )
    {
        this();
        switch (resolver){
        case qq_Resolver.cFILLCOLOR_PENCOLOR:
            this.setForeground(UIutils.forteToJavaColor(param2));
            this.setBackground(UIutils.forteToJavaColor(param1));
            break;
        case qq_Resolver.cPENCOLOR_FILLCOLOR:
            this.setForeground(UIutils.forteToJavaColor(param1));
            this.setBackground(UIutils.forteToJavaColor(param2));
            break;
        case qq_Resolver.cX_Y:
          setLocation(param1, param2);
          break;
        }
    }
    public Point( int symbol, int point1, int point2, int resolver )
    {
        this();
        switch (resolver){
        case qq_Resolver.cSYMBOL_X_Y:
            this.setSymbol(symbol);
            this.setLocation(UIutils.milsToPixels(point1), UIutils.milsToPixels(point2));
            break;
        }
    }
    public Point( int symbol, int resolver )
    {
      this();
      switch (resolver){
      case qq_Resolver.cSYMBOL:
        this.setSymbol(symbol);
        break;
      }
    }

    public void paintComponent(Graphics g) {
        Graphics gFill = g.create();
        Insets insets = this.getInsets();
        switch (Symbol){
        case Constants.PS_CIRCLE:
            gFill.setColor( this.getForeground() );
            gFill.fillOval(insets.left, insets.top, this.getWidth() - insets.left + insets.right-1, this.getHeight() - insets.top + insets.bottom-1);
            break;
        case Constants.PS_CROSS:
            gFill.setColor( this.getForeground() );
            cross(gFill);
            break;
        case Constants.PS_DIAMOND:
            gFill.setColor( this.getForeground() );
            gFill.fillPolygon(
                    new int[] {getWidth() / 2, getWidth(), getWidth() / 2, 0}, // X points
                    new int[] {0, getHeight() / 2, getHeight(), getHeight() / 2}, // Y points
                    4);
            break;
        case Constants.PS_PIXEL:
            gFill.setColor( this.getForeground() );
            gFill.fillRect(0, 0, 1, 1);
            break;
        case Constants.PS_PLUS:
            gFill.setColor( this.getForeground() );
            plus(gFill);
            break;
        case Constants.PS_SQUARE:
            gFill.setColor( this.getForeground() );
            gFill.fillRect(insets.left, insets.top, this.getWidth() - insets.left + insets.right, this.getHeight() - insets.top + insets.bottom );
            break;
        case Constants.PS_STAR:
            gFill.setColor( this.getForeground() );
            plus(gFill);
            cross(gFill);
            break;
        case Constants.PS_TRIANGLEDOWN:
            gFill.setColor( this.getForeground() );
            gFill.fillPolygon(
                    new int[] {0, getWidth(), getWidth() / 2}, // X points
                    new int[] {0, 0, getHeight()}, // Y points
                    3);
            break;
        case Constants.PS_TRIANGLELEFT:
            gFill.setColor( this.getForeground() );
            gFill.fillPolygon(
                    new int[] {0, getWidth(), getWidth()}, // X points
                    new int[] {getHeight() / 2, 0, getHeight()}, // Y points
                    3);
            break;
        case Constants.PS_TRIANGLERIGHT:
            gFill.fillPolygon(
                    new int[] {0, getWidth(), 0}, // X points
                    new int[] {0, getHeight() / 2, getHeight()}, // Y points
                    3);
            break;
        case Constants.PS_TRIANGLEUP:
            gFill.setColor( this.getForeground() );
            gFill.fillPolygon(
                    new int[] {getWidth(), getWidth() / 2, 0}, // X points
                    new int[] {getHeight(), 0, getHeight()}, // Y points
                    3);
            break;
        }
        gFill.dispose();
    }
    public String getName() {
        return Name;
    }
    public void setName(String name) {
        Name = name;
    }
    public int getSymbol() {
        return Symbol;
    }
    /**
     * The Symbol attribute (integer) specifies the graphic symbol a point uses to display itself. It uses the following values:
     * PS_DEFAULT  Exactly one pixel.
     * PS_CIRCLE  A circle.
     * PS_CROSS  A cross, displayed as an X.
     * PS_DIAMOND  A diamond.
     * PS_PIXEL  Exactly one pixel.
     * PS_PLUS  A plus sign.
     * PS_SQUARE  A square.
     * PS_STAR  A star burst.
     * PS_TRIANGLEDOWN  A downward-pointing triangle.
     * PS_TRIANGLERIGHT  A right-pointing triangle.
     * PS_TRIANGLEUP  An upward-pointing triangle.
     * PS_TRIANGLELEFT  A left-pointing triangle.
     * @param symbol
     */
    public void setSymbol(int symbol) {
        Symbol = symbol;
        invalidate();
    }
    public void setMinimumSize(Dimension minimumSize) {
        minimumSize.height = Math.max(minimumSize.height, 1);
        minimumSize.width = Math.max(minimumSize.width, 1);
        super.setMinimumSize(minimumSize);
    }
    public void setSize(Dimension minimumSize) {
        minimumSize.height = Math.max(minimumSize.height, 1);
        minimumSize.width = Math.max(minimumSize.width, 1);
        super.setSize(minimumSize);
    }
    protected void plus(Graphics gFill){
        gFill.drawLine(getInsets().left, this.getHeight() / 2, this.getWidth(), this.getHeight() / 2);
        gFill.drawLine(this.getWidth() / 2, getInsets().top, this.getWidth() / 2, this.getHeight());

    }
    protected void cross(Graphics gFill){
        gFill.drawLine(getInsets().left, getInsets().top, this.getWidth(), this.getHeight());
        gFill.drawLine(getInsets().left, this.getHeight(), this.getWidth(), getInsets().top);
    }
    public int getXCenterPixel(){
        return ((int)this.getLocation().x + (this.getWidth()/2));
    }
    public void setXCenterPixel(int value){
        this.setLocation(value, this.getLocation().y);
    }
    public void setYCenterPixel(int value){
        this.setLocation(this.getLocation().x, value);
    }
    public int getYCenterPixel(){
        return ((int)this.getLocation().y + (this.getHeight()/2));
    }
    public int getXCenter(){
        return UIutils.pixelsToMils(this.getXCenterPixel());
    }
    public int getYCenter(){
        return UIutils.pixelsToMils(this.getYCenterPixel());
    }
    public void setXCenter(int value){
        this.setXCenterPixel(UIutils.milsToPixels(value));
    }
    public void setYCenter(int value){
        this.setYCenterPixel(UIutils.milsToPixels(value));
    }
    public Point cloneComponent(){
        Point clone = new Point();
        CloneHelper.cloneComponent(this, clone, new String[]{"parent"});
        return clone;
    }
}
TOP

Related Classes of DisplayProject.controls.Point$qq_Resolver

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.