Back to index

wims  3.65+svn20090927
DisplayableImpl.java
Go to the documentation of this file.
00001 /*
00002 $Id: DisplayableImpl.java,v 1.3 2003/02/18 11:48:46 sander Exp $
00003 */
00004 
00005 
00006 /*
00007 Copyright (C) 2001-2002 Mainline Project (I3S - ESSI - CNRS -UNSA)
00008 
00009 This library is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU Lesser General Public
00011 License as published by the Free Software Foundation; either
00012 version 2.1 of the License, or (at your option) any later version.
00013 
00014 This library is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public
00020 License along with this library; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023 For further information on the GNU Lesser General Public License,
00024 see: http://www.gnu.org/copyleft/lesser.html
00025 For further information on this library, contact: mainline@essi.fr
00026 */
00027 
00028 
00029 package fr.ove.openmath.jome.ctrlview.bidim;
00030 
00031 import java.awt.*;
00032 import java.io.Serializable;
00033 import fr.ove.openmath.jome.ctrlview.bidim.GraphicContext;
00034 import fr.ove.openmath.jome.ctrlview.bidim.Sizable;
00035 import fr.ove.openmath.jome.ctrlview.bidim.Localisable;
00036 
00045 public abstract class DisplayableImpl implements Displayable, Serializable {
00049     private Rectangle bounds;
00050     
00055     private int ascent;
00056 
00061     private int descent;
00062 
00066     private int shiftX;
00067 
00071     private int shiftY;
00072     
00076     private GraphicContext graphicContext;
00077     
00082     public DisplayableImpl() {
00083         this(new Rectangle(), 0, 0, 0, 0);
00084     }
00085     
00094     public DisplayableImpl(Rectangle bounds, int ascent, int descent, int shiftX, int shiftY) {
00095         this.bounds = bounds;
00096         this.ascent = ascent;
00097         this.descent = descent;
00098         this.shiftX = shiftX;
00099         this.shiftY = shiftY;
00100     }
00101     
00102     
00103     // #################################################
00104     // ### Implémentation des différentes interfaces ###
00105     // #################################################
00106     
00107     // *************************************************
00108     // *** Implémentation de l'interface Displayable ***
00109     
00114     public void setAscent(int ascent) {
00115         this.ascent = ascent;
00116     }
00117     
00122     public int getAscent() {
00123         return ascent;
00124     }
00125     
00130     public void setDescent(int descent) {
00131         this.descent = descent;
00132     }
00133     
00138     public int getDescent() {
00139         return descent;
00140     }
00141     
00146     public void setShiftX(int shiftX) {
00147         this.shiftX = shiftX;
00148     }
00149     
00154     public int getShiftX() {
00155         return shiftX;
00156     }
00157     
00162     public void setShiftY(int shiftY) {
00163         this.shiftY = shiftY;
00164     }
00165     
00170     public int getShiftY() {
00171         return shiftY;
00172     }
00173     
00181     public void setAttributes(int ascent, int descent, int shiftX, int shiftY) {
00182         this.ascent = ascent;
00183         this.descent = descent;
00184         this.shiftX = shiftX;
00185         this.shiftY = shiftY;
00186     }
00187     
00192     public void setGraphicContext(GraphicContext graphicContext) {
00193         // contrairement à la création d'un display, il n'y a pas allocation mais maintient d'une référence
00194         // sur graphicContext, qui est en fait le contexte graphique du display (dans notre cas précis) qui
00195         // va afficher l'objet.
00196         this.graphicContext = graphicContext;
00197     }
00198     
00202     public GraphicContext getGraphicContext() {
00203         return graphicContext;
00204     }
00205     
00206     // *** Fin de l'interface Displayable ***
00207     // **************************************
00208     
00209     // *************************************************
00210     // *** Implémentation de l'interface Localisable ***
00211     
00216     public void setX(int x) {
00217         bounds.x = x;
00218     }
00219     
00223     public int getX() {
00224         return bounds.x;
00225     }
00226     
00231     public void setY(int y) {
00232         bounds.y = y;
00233     }
00234     
00238     public int getY() {
00239         return bounds.y;
00240     }
00241     
00247     public void setLocation(int x, int y) {
00248         bounds.setLocation(x, y);
00249     }
00250     
00255     public void setLocation(Point location) {
00256         bounds.setLocation(location);
00257     }
00258     
00263     public Point getLocation() {
00264         return bounds.getLocation();
00265     }
00266     
00267     // *** Fin de l'interface Localisable ***
00268     // **************************************
00269     
00270     // *********************************************
00271     // *** Implémentation de l'interface Sizable ***
00272     
00276     public int getWidth() {
00277         return bounds.width;
00278     }
00279     
00284     public void setWidth(int width) {
00285         bounds.width = width;
00286     }
00287     
00291     public int getHeight() {
00292         return bounds.height;
00293     }
00294     
00299     public void setHeight(int height) {
00300         bounds.height = height;
00301     }
00302     
00306     public Dimension getSize() {
00307         return bounds.getSize();
00308     }
00309     
00315     public void setSize(int width, int height) {
00316         bounds.setSize(width, height);
00317     }
00318     
00323     public void setSize(Dimension size) {
00324         bounds.setSize(size);
00325     }
00326     
00327     // Le comportement par défaut est que la taille de bounds est la taille préférée.
00331     public Dimension getPreferredSize() {
00332         return bounds.getSize();
00333     }
00334     
00335     // *** Fin de l'interface sizable ***
00336     // **********************************
00337 }