001 /*
002 * Copyright 2002 - 2006 JEuclid, http://jeuclid.sf.net
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 /* $Id: DisplayableNode.java 310 2007-05-18 20:26:36Z maxberger $ */
018
019 package net.sourceforge.jeuclid.elements;
020
021 import java.awt.Graphics2D;
022
023 /**
024 * Any node that can be displayed on screen. This is the start of a generic
025 * interface that should support all types of Nodes.
026 *
027 * @author Max Berger
028 * @version $Revision: 310 $
029 */
030 public interface DisplayableNode {
031
032 /**
033 * Paints this element.
034 *
035 * @param g
036 * The graphics context to use for painting
037 * @param posX
038 * The first left position for painting
039 * @param posY
040 * The position of the baseline
041 */
042 void paint(Graphics2D g, float posX, float posY);
043
044 /**
045 * Returns the current height of the upper part of this component from the
046 * baseline.
047 *
048 * @return Height of the upper part
049 * @param g
050 * Graphics2D context to use.
051 */
052 float getAscentHeight(Graphics2D g);
053
054 /**
055 * Returns the current height of the lower part of this component from the
056 * baseline.
057 *
058 * @return Height of the lower part.
059 * @param g
060 * Graphics2D context to use.
061 */
062 float getDescentHeight(Graphics2D g);
063
064 /**
065 * Return the current height of this element.
066 *
067 * @return Height of this element
068 * @param g
069 * Graphics2D context to use.
070 */
071 float getHeight(Graphics2D g);
072
073 /**
074 * Returns the current width of this element.
075 *
076 * @return Width of this element.
077 * @param g
078 * Graphics2D context to use.
079 */
080 float getWidth(Graphics2D g);
081
082 /**
083 * Returns the center X coordinate of the content. In most cases, this
084 * will be width/2. In some cases, an element may have extra space on one
085 * side, therefore moving the content.
086 *
087 * @param g
088 * X-offset of the horizontal center of the actual content.
089 * @return Graphics2D context to use.
090 */
091 float getXCenter(Graphics2D g);
092
093 /**
094 * Returns the last X position this node was painted on. May return -1 if
095 * the node was not painted recently.
096 *
097 * @return the x position.
098 */
099 float getPaintedPosX();
100
101 /**
102 * Returns the last Y position this node was painted on. May return -1 if
103 * the node was not painted recently.
104 *
105 * @return the y position.
106 */
107 float getPaintedPosY();
108
109 }