Annotation of java/classes/org/w3c/rdf/Arc.java, revision 1.1

1.1     ! jsaarela    1: /**
        !             2:  * A simple placeholder for Arc data
        !             3:  *
        !             4:  * Copyright © World Wide Web Consortium, (Massachusetts Institute of
        !             5:  * Technology, Institut National de Recherche en Informatique et en
        !             6:  * Automatique, Keio University).
        !             7:  *
        !             8:  * All Rights Reserved.
        !             9:  *
        !            10:  * Please see the full Copyright clause at
        !            11:  * <http://www.w3.org/Consortium/Legal/copyright-software.html>
        !            12:  *
        !            13:  * $Log$
        !            14:  *
        !            15:  * @author     Janne Saarela <jsaarela@w3.org>
        !            16:  */
        !            17: package org.w3c.rdf;
        !            18: 
        !            19: import java.awt.Point;
        !            20: import java.awt.Color;
        !            21: 
        !            22: public class Arc {
        !            23:     private String     m_sRelation = null;
        !            24:     private Point      m_start = null;
        !            25:     private Point      m_end = null;
        !            26:     private Point      m_middle = null;
        !            27:     private Color      m_color = Color.black;
        !            28:     private Node       m_startNode = null;
        !            29:     private Node       m_endNode = null;
        !            30: 
        !            31:     static public boolean      SHORTNAMES = true;
        !            32: 
        !            33:     public static final Color DEFAULT_COLOR = Color.black;
        !            34:     public static final Color SELECTED_COLOR = Color.green;
        !            35: 
        !            36:     public Arc (String sRelation,
        !            37:                Point start,
        !            38:                Point end,
        !            39:                Node startNode,
        !            40:                Node endNode) {
        !            41:        m_sRelation = sRelation;
        !            42:        m_start = start;
        !            43:        m_end = end;
        !            44:        m_middle = new Point ((start.x+end.x)/2, (start.y+end.y)/2);
        !            45:        m_startNode = startNode;
        !            46:        m_endNode = endNode;
        !            47:     }
        !            48: 
        !            49:     public Point start () {
        !            50:        return m_start;
        !            51:     }
        !            52: 
        !            53:     public Point end () {
        !            54:        return m_end;
        !            55:     }
        !            56: 
        !            57:     public String visualRelation() {
        !            58:        if (SHORTNAMES) {
        !            59:            int iHashIndex = m_sRelation.lastIndexOf('#');
        !            60:            if (iHashIndex > -1)
        !            61:                return m_sRelation.substring (iHashIndex+1);
        !            62:            else
        !            63:                return m_sRelation;
        !            64:        } else {
        !            65:            return m_sRelation;
        !            66:        }
        !            67:     }
        !            68: 
        !            69:     public String relation() {
        !            70:        return m_sRelation;
        !            71:     }
        !            72: 
        !            73:     /**
        !            74:      * Return the distance of the point <i>p</i> from the middle
        !            75:      * point of the Arc (Do not take square root for efficiency)
        !            76:      */
        !            77:     public double distance (Point p) {
        !            78:        int dx = m_middle.x - p.x;
        !            79:        int dy = m_middle.y - p.y;
        !            80:        return dx*dx + dy*dy;
        !            81:     }
        !            82: 
        !            83:     public Color color () {
        !            84:        return m_color;
        !            85:     }
        !            86:     
        !            87:     public void setColor (Color c) {
        !            88:        m_color = c;
        !            89:     }
        !            90: }
        !            91: 

Webmaster