/** * A simple placeholder for Arc data * * Copyright © World Wide Web Consortium, (Massachusetts Institute of * Technology, Institut National de Recherche en Informatique et en * Automatique, Keio University). * * All Rights Reserved. * * Please see the full Copyright clause at * * * $Log: Arc.java,v $ * Revision 1.1 1999/01/13 15:00:17 jsaarela * Finished conformance testing with PR-rdf-syntax-19990105 version * of the RDF M&S spec. * * * @author Janne Saarela */ package org.w3c.rdf; import java.awt.Point; import java.awt.Color; public class Arc { private String m_sRelation = null; private Point m_start = null; private Point m_end = null; private Point m_middle = null; private Color m_color = Color.black; private Node m_startNode = null; private Node m_endNode = null; static public boolean SHORTNAMES = true; public static final Color DEFAULT_COLOR = Color.black; public static final Color SELECTED_COLOR = Color.green; public Arc (String sRelation, Point start, Point end, Node startNode, Node endNode) { m_sRelation = sRelation; m_start = start; m_end = end; m_middle = new Point ((start.x+end.x)/2, (start.y+end.y)/2); m_startNode = startNode; m_endNode = endNode; } public Point start () { return m_start; } public Point end () { return m_end; } public String visualRelation() { if (SHORTNAMES) { int iHashIndex = m_sRelation.lastIndexOf('#'); if (iHashIndex > -1) return m_sRelation.substring (iHashIndex+1); else return m_sRelation; } else { return m_sRelation; } } public String relation() { return m_sRelation; } /** * Return the distance of the point p from the middle * point of the Arc (Do not take square root for efficiency) */ public double distance (Point p) { int dx = m_middle.x - p.x; int dy = m_middle.y - p.y; return dx*dx + dy*dy; } public Color color () { return m_color; } public void setColor (Color c) { m_color = c; } }