Statistics
| Revision:

root / trunk / libraries / libUIComponent / src / org / gvsig / gui / beans / imagenavigator / ImageNavigator.java @ 13022

History | View | Annotate | Download (18.2 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.gui.beans.imagenavigator;
20

    
21
import java.awt.AlphaComposite;
22
import java.awt.Color;
23
import java.awt.Cursor;
24
import java.awt.GradientPaint;
25
import java.awt.Graphics;
26
import java.awt.Graphics2D;
27
import java.awt.Image;
28
import java.awt.Point;
29
import java.awt.RenderingHints;
30
import java.awt.event.KeyEvent;
31
import java.awt.event.KeyListener;
32
import java.awt.event.MouseEvent;
33
import java.awt.event.MouseListener;
34
import java.awt.event.MouseMotionListener;
35
import java.awt.event.MouseWheelEvent;
36
import java.awt.event.MouseWheelListener;
37

    
38
import javax.swing.ImageIcon;
39
import javax.swing.JComponent;
40

    
41
import org.gvsig.gui.beans.messages.Messages;
42
/**
43
 * <code>ImageNavigator</code> es un componente que representa un manejador
44
 * de im?genes. En ?l se puede desplazar, hacer un zoom out o un zoom in a una
45
 * imagen virtual. El componente no trata la imagen en si, solo lanza los
46
 * eventos indicando la nueva posici?n y zoom de la imagen, luego es el usuario
47
 * el que se encargar? de dibujar esa imagen en la posici?n correspondiente.
48
 *
49
 * El modo de uso es el siguiente:
50
 * - Se puede desplazar una imagen con el bot?n izquierdo del rat?n.
51
 * - Se puede hacer zoom in/out con las teclas +/- del teclado.
52
 * - Se puede hacer zoom in/out con la rueda del rat?n teniendo en cuenta la
53
 * posici?n del mismo.
54
 * - Se puede resetear los valores con las teclas 'Espacio' o 0;
55
 * - Las teclas 1, 2, 3, 4 y 5 equivalen a zoom 1, 2, 4, 8 y 16 respectivamente.
56
 * - La tecla C sirve para centrar la imagen.
57
 * - La tecla H muestra la ayuda.
58
 *
59
 * @version 04/05/2007
60
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
61
 */
62
public class ImageNavigator extends JComponent implements KeyListener, MouseMotionListener, MouseListener, MouseWheelListener {
63
        private static final long serialVersionUID = 1164788214432359272L;
64
        private IClientImageNavigator iClient        = null;
65

    
66
        private Image                 image          = null;
67
        private Graphics2D            widgetGraphics = null;
68
        private Image                 imageCache     = null;
69
        private Graphics2D            cacheGraphics  = null;
70

    
71
        private double                zoom           = 1.0;
72
        private double                x1             = 0.0;
73
        private double                y1             = 0.0;
74
        private boolean               yInverted      = false;
75
        private boolean               xInverted      = false;
76
        private int                   width          = 0;
77
        private int                   height         = 0;
78
        private boolean               showHelp       = false;
79
        ImageIcon                     imageIconClose;
80
        ImageIcon                     imageIconHelp;
81

    
82
        /**
83
         * Crea un <code>ImageNavigator</code> especificandole quien pintara el
84
         * componente
85
         * @param iClient
86
         */
87
        public ImageNavigator(IClientImageNavigator iClient) {
88
                this.iClient = iClient;
89

    
90
                this.setFocusable(true);
91
                this.addKeyListener(this);
92
                this.addMouseMotionListener(this);
93
                this.addMouseListener(this);
94
                this.addMouseWheelListener(this);
95
        }
96

    
97
        double initX1 = 0.0;
98
        double initY1 = 0.0;
99
        double initX2 = 100.0;
100
        double initY2 = 100.0;
101
        double initZoom = 1.0;
102
        boolean autoAdjusted = true;
103

    
104
        /**
105
         * Actualiza las dimensiones para ajustar la imagen a los bordes especificados
106
         * con setViewDimensions.
107
         */
108
        private void updateDimensions() {
109
                double factor = this.getWidth() / (initX2 - initX1);
110
                if (factor > (this.getHeight() / (initY2 - initY1)))
111
                        factor = this.getHeight() / (initY2 - initY1);
112
                zoom = factor;
113
                imageCenter();
114
        }
115

    
116
        /**
117
         * Centra la imagen
118
         */
119
        public void imageCenter() {
120
                x1 = initX1;
121
                y1 = initY1;
122

    
123
                if (isXInverted())
124
                        x1 -= ((initX2 - initX1) - this.getWidth() / zoom) / 2.0;
125
                else
126
                        x1 += ((initX2 - initX1) - this.getWidth() / zoom) / 2.0;
127
                if (isYInverted())
128
                        y1 -= ((initY2 - initY1) - this.getHeight() / zoom) / 2.0;
129
                else
130
                        y1 += ((initY2 - initY1) - this.getHeight() / zoom) / 2.0;
131
        }
132

    
133
        /**
134
         * Especifica el rectangulo de la imagen a visualizar, pudiendo tener
135
         * cualquiera de los ejes X e Y invertidos
136
         *
137
         * @param x1 Coordenada izquierda
138
         * @param y1 Coordenada superior
139
         * @param x2 Coordenada derecha
140
         * @param y2 Coordenada inferior
141
         */
142
        public void setViewDimensions(double x1, double y1, double x2, double y2) {
143
                this.initX1 = x1;
144
                this.initX2 = x2;
145
                this.initY1 = y1;
146
                this.initY2 = y2;
147

    
148
                yInverted = (y2 < y1);
149
                if (yInverted) {
150
                        this.initY1 = y2;
151
                        this.initY2 = y1;
152
                }
153

    
154
                xInverted = (x2 < x1);
155
                if (xInverted) {
156
                        this.initX1 = x2;
157
                        this.initX2 = x1;
158
                }
159

    
160
                this.updateDimensions();
161
        }
162

    
163
        /**
164
         * Hace un forzado de pintado del buffer temporal de la imagen. Este m?todo
165
         * forzar? una llamada a la funci?n de pintado del cliente.
166
         */
167
        public void updateBuffer() {
168
                updateImageCache(true);
169
                refreshImage(0, 0);
170
        }
171

    
172
        /**
173
         * Especifica el zoom que usar? por defecto el componente.
174
         * @param zoom
175
         */
176
        public void setZoom(double zoom) {
177
                initZoom = zoom;
178
                this.zoom = initZoom;
179
                autoAdjusted = false;
180
                imageCenter();
181
        }
182

    
183
        /**
184
         * Especifica el zoom que usar? por defecto el componente.
185
         * @param zoom
186
         */
187
        public void setAutoAdjusted() {
188
                autoAdjusted = true;
189
                updateDimensions();
190
                updateImageCache(true);
191
                refreshImage(0, 0);
192
        }
193

    
194
        /*
195
         * (non-Javadoc)
196
         * @see javax.swing.JComponent#addNotify()
197
         */
198
        public void addNotify() {
199
                super.addNotify();
200

    
201
                updateImageCache(true);
202
                refreshImage(0, 0);
203
        }
204

    
205
        /**
206
         * Hace un zoom de aumento en las coordenadas especificadas
207
         * @param x
208
         * @param y
209
         */
210
        private void ZoomIn(double x, double y) {
211
                if ((int) (zoom * 100.0) >= (25600.0 / initZoom))
212
                        return;
213
                double xcent = (x / zoom);
214
                double ycent = (y / zoom);
215
                if (isXInverted())
216
                        x1 -= xcent;
217
                else
218
                        x1 += xcent;
219
                if (isYInverted())
220
                        y1 -= ycent;
221
                else
222
                        y1 += ycent;
223
                zoom = zoom * 2.0;
224
                xcent = (x / zoom);
225
                ycent = (y / zoom);
226
                if (isXInverted())
227
                        x1 += xcent;
228
                else
229
                        x1 -= xcent;
230
                if (isYInverted())
231
                        y1 += ycent;
232
                else
233
                        y1 -= ycent;
234
                updateImageCache(true);
235
                refreshImage(0, 0);
236
        }
237

    
238
        /**
239
         * Hace un zoom hacia afuera en las coordenadas especificadas
240
         * @param x
241
         * @param y
242
         */
243
        private void ZoomOut(double x, double y) {
244
                if ((int) ((1.0 / zoom) * 100.0) >= (25600.0 / initZoom))
245
                        return;
246

    
247
                double xcent = (x / zoom);
248
                double ycent = (y / zoom);
249
                if (isXInverted())
250
                        x1 -= xcent;
251
                else
252
                        x1 += xcent;
253
                if (isYInverted())
254
                        y1 -= ycent;
255
                else
256
                        y1 += ycent;
257
                zoom = zoom / 2.0;
258
                xcent = (x / zoom);
259
                ycent = (y / zoom);
260
                if (isXInverted())
261
                        x1 += xcent;
262
                else
263
                        x1 -= xcent;
264
                if (isYInverted())
265
                        y1 += ycent;
266
                else
267
                        y1 -= ycent;
268
                updateImageCache(true);
269
                refreshImage(0, 0);
270
        }
271

    
272
        /**
273
         * Mostrar o ocultar la ayuda
274
         *
275
         */
276
        private void callShowHelp() {
277
                showHelp = !showHelp;
278
                updateImageCache(true);
279
                refreshImage(0, 0);
280
        }
281

    
282
        /*
283
         * (non-Javadoc)
284
         * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
285
         */
286
        public void keyPressed(KeyEvent e) {
287
                switch (e.getKeyChar()) {
288
                        case 'h':
289
                        case 'H':
290
                                callShowHelp();
291
                                break;
292
                        case '+':
293
                                ZoomIn(width / 2.0, height / 2.0);
294
                                autoAdjusted = false;
295
                                break;
296
                        case '-':
297
                                ZoomOut(width / 2.0, height / 2.0);
298
                                autoAdjusted = false;
299
                                break;
300
                        case '1':
301
                                autoAdjusted = false;
302
                                this.zoom = initZoom;
303
                                imageCenter();
304
                                updateImageCache(true);
305
                                refreshImage(0, 0);
306
                                break;
307
                        case '2':
308
                                autoAdjusted = false;
309
                                this.zoom = initZoom * 2.0;
310
                                imageCenter();
311
                                updateImageCache(true);
312
                                refreshImage(0, 0);
313
                                break;
314
                        case '3':
315
                                autoAdjusted = false;
316
                                this.zoom = initZoom * 4.0;
317
                                imageCenter();
318
                                updateImageCache(true);
319
                                refreshImage(0, 0);
320
                                break;
321
                        case '4':
322
                                autoAdjusted = false;
323
                                this.zoom = initZoom * 8.0;
324
                                imageCenter();
325
                                updateImageCache(true);
326
                                refreshImage(0, 0);
327
                                break;
328
                        case '5':
329
                                autoAdjusted = false;
330
                                this.zoom = initZoom * 16.0;
331
                                imageCenter();
332
                                updateImageCache(true);
333
                                refreshImage(0, 0);
334
                                break;
335
                        case 'c':
336
                        case 'C':
337
                                imageCenter();
338
                                updateImageCache(true);
339
                                refreshImage(0, 0);
340
                                break;
341
                        case '0':
342
                        case ' ':
343
                                setAutoAdjusted();
344
                                break;
345
                }
346
        }
347

    
348
        double updateWidth = 0;
349
        double updateHeight = 0;
350
        /**
351
         * M?todo que hara la invocaci?n al cliente del pintado del trozo de imagen a
352
         * visualizar
353
         * @param forceUpdate
354
         */
355
        private void updateImageCache(boolean forceUpdate) {
356
                if (getWidgetImage() == null ||
357
                                (updateWidth == getWidgetImage().getWidth(this) &&
358
                                updateHeight == getWidgetImage().getHeight(this) &&
359
                                !forceUpdate))
360
                        return;
361
                updateWidth = getWidgetImage().getWidth(this);
362
                updateHeight = getWidgetImage().getHeight(this);
363

    
364
                for (int i = 0; (i * 4) <= width; i++) {
365
                        for (int j = 0; (j * 4) <= height; j++) {
366
                                if ((i + j) % 2 == 0)
367
                                        getCacheGraphics().setColor(Color.white);
368
                                else
369
                                        getCacheGraphics().setColor(new Color(204, 204, 204));
370
                                getCacheGraphics().fillRect(i * 4, j * 4, 4, 4);
371
                        }
372
                }
373
/*
374
                getCacheGraphics().setColor(Color.WHITE);
375
                getCacheGraphics().fillRect(0, 0, width, height);
376
*/
377

    
378
                double newY1 = 0.0;
379
                double newY2 = 0.0;
380
                double newX1 = 0.0;
381
                double newX2 = 0.0;
382
                if (isYInverted()) {
383
                        newY1 = y1 + this.getHeight() / zoom - ((y1 - initY1) * 2.0);
384
                        newY2 = newY1 - this.getHeight() / zoom;
385
                } else {
386
                        newY1 = y1;
387
                        newY2 = y1 + this.getHeight() / zoom;
388
                }
389
                if (isXInverted()) {
390
                        newX1 = x1 + this.getWidth() / zoom - ((x1 - initX1) * 2.0);
391
                        newX2 = newX1 - this.getWidth() / zoom;
392
                } else {
393
                        newX1 = x1;
394
                        newX2 = x1 + this.getWidth() / zoom;
395
                }
396
                iClient.drawImage(getCacheGraphics(), newX1, newY1, newX2, newY2, zoom, this.getWidth(), this.getHeight());
397
        }
398

    
399
        private Image getWidgetImage() {
400
                int width2 = getBounds().width;
401
                int height2 = getBounds().height;
402
                if (width2 <= 0)
403
                        width2 = 1;
404
                if (height2 <= 0)
405
                        height2=1;
406

    
407
                if ((width != width2) || (height != height2)) {
408
                        image = createImage(width2, height2);
409
                        imageCache = createImage(width2, height2);
410
                        if (image == null)
411
                                return null;
412
                        widgetGraphics = (Graphics2D) image.getGraphics();
413
                        cacheGraphics = (Graphics2D) imageCache.getGraphics();
414

    
415
                        RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
416
                        hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
417
                        cacheGraphics.setRenderingHints(hints);
418
                }
419

    
420
                width = width2;
421
                height = height2;
422
                return image;
423
        }
424

    
425
        private Graphics2D getWidgetGraphics() {
426
                getWidgetImage();
427
                return widgetGraphics;
428
        }
429

    
430
        private Graphics2D getCacheGraphics() {
431
                getWidgetImage();
432
                return cacheGraphics;
433
        }
434

    
435
        /**
436
         * Redibujar el componente en el graphics temporal
437
         */
438
        private void redrawBuffer(int x, int y) {
439
                for (int i = -2; ((i - 2) * 4) <= width; i++) {
440
                        for (int j = -2; ((j - 2) * 4) <= height; j++) {
441
                                if ((i + j) % 2 == 0)
442
                                        getWidgetGraphics().setColor(Color.white);
443
                                else
444
                                        getWidgetGraphics().setColor(new Color(204, 204, 204));
445
                                getWidgetGraphics().fillRect((i * 4) + (x % 8), (j * 4) + (y % 8), 4, 4);
446
                        }
447
                }
448
/*
449
                getWidgetGraphics().setColor(new Color(204, 204, 204));
450
                getWidgetGraphics().fillRect(0, 0, width, height);
451
*/
452

    
453
                getWidgetGraphics().drawImage(imageCache, x, y, null);
454

    
455
                if (showHelp)
456
                        paintHelp((Graphics2D) getWidgetGraphics());
457
                else
458
                        getWidgetGraphics().drawImage(getIconHelp().getImage(), width - getIconHelp().getIconWidth() - 4, 3, null);
459
        }
460

    
461
        /*
462
         * (non-Javadoc)
463
         * @see javax.swing.JComponent#paint(java.awt.Graphics)
464
         */
465
        public void paint(Graphics g) {
466
                if (autoAdjusted) updateDimensions();
467
                Graphics2D g2d = (Graphics2D) g;
468
                RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
469
                hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
470
                g2d.setRenderingHints(hints);
471

    
472
                updateImageCache(false);
473

    
474
                redrawBuffer(0, 0);
475

    
476
                if (image != null)
477
                        g.drawImage(image, 0, 0, this);
478

    
479
//                paintHelp((Graphics2D) g);
480
        }
481

    
482
        /**
483
         * Redibujar el componente en el graphics temporal y representarlo en el
484
         * componente
485
         */
486
        private void refreshImage(int x, int y) {
487
                Graphics2D g2d = (Graphics2D) getGraphics();
488
                if (g2d == null)
489
                        return;
490
                RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
491
                hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
492
                g2d.setRenderingHints(hints);
493
                redrawBuffer(x, y);
494

    
495
                if (image != null)
496
                        getGraphics().drawImage(image, 0, 0, this);
497

    
498
//                paintHelp((Graphics2D) getGraphics());
499
        }
500

    
501
        /**
502
         * Devuelve el icono de cerrar
503
         * @return
504
         */
505
        private ImageIcon getIconClose() {
506
                if (imageIconClose == null) {
507
                        imageIconClose = new ImageIcon(getClass().getResource("images/close.png"));
508
                }
509
                return imageIconClose;
510
        }
511

    
512
        /**
513
         * Devuelve el icono ayuda
514
         * @return
515
         */
516
        private ImageIcon getIconHelp() {
517
                if (imageIconHelp == null) {
518
                        imageIconHelp = new ImageIcon(getClass().getResource("images/help.png"));
519
                }
520
                return imageIconHelp;
521
        }
522

    
523
        private void paintHelp(Graphics2D g) {
524
                int sep = 13;
525
                int pos = sep + 1;
526

    
527
                int alto = sep * 7 + 6;
528

    
529
                Image image2 = createImage(width, alto);
530
                Graphics2D graphics2 = (Graphics2D) image2.getGraphics();
531

    
532
                RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
533
                hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
534
                graphics2.setRenderingHints(hints);
535

    
536
                alto--;
537

    
538
                Color color1 = new Color(255, 255, 178);
539
                Color color2 = new Color(255, 255, 74);
540
                graphics2.setPaint(new GradientPaint(0, 0, color1, 0, alto, color2, false));
541
                graphics2.fillRect(0, 0, width, alto);
542

    
543
                graphics2.setColor(new Color(0, 0, 0));
544

    
545
                graphics2.setFont(new java.awt.Font("Tahoma", 1, sep - 2));
546

    
547
                graphics2.drawString(Messages.getText("teclas") + ":", 10, pos);
548

    
549
                graphics2.setFont(new java.awt.Font("Tahoma", 0, sep - 2));
550
                pos+=sep;
551
                graphics2.drawString(Messages.getText("ayuda_c"), 20, pos);
552
                pos+=sep;
553
                graphics2.drawString(Messages.getText("ayuda_0"), 20, pos);
554
                pos+=sep;
555
                graphics2.drawString(Messages.getText("ayuda_1_5"), 20, pos);
556
                pos+=sep;
557
                graphics2.drawString(Messages.getText("ayuda_more_less"), 20, pos);
558
                pos+=sep;
559
                graphics2.drawString(Messages.getText("ayuda_wheel"), 20, pos);
560
                pos+=sep;
561
                graphics2.drawString(Messages.getText("ayuda_h"), 20, pos);
562

    
563
                graphics2.setColor(new Color(185, 185, 185));
564
                graphics2.drawLine(0, alto, width, alto);
565

    
566
                graphics2.drawImage(getIconClose().getImage(), width - getIconClose().getIconWidth() - 4, 3, null);
567

    
568
                AlphaComposite myAlpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f);
569
                g.setComposite(myAlpha);
570

    
571
                g.drawImage(image2, 0, 0, this);
572

    
573
                myAlpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f);
574
                g.setComposite(myAlpha);
575
        }
576

    
577
        Point mouse = null;
578
        /*
579
         * (non-Javadoc)
580
         * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
581
         */
582
        public void mousePressed(MouseEvent e) {
583
                requestFocus();
584

    
585
                if ((e.getX() > (width - 20)) && (e.getY() < 20))
586
                        return;
587

    
588
                if ((e.getButton() != MouseEvent.BUTTON1) && (e.getButton() != MouseEvent.BUTTON2))
589
                        return;
590

    
591
                Color gris = new Color(0, 0, 0, 16);
592
                getCacheGraphics().setColor(gris);
593
                getCacheGraphics().fillRect(0, 0, width-1, height-1);
594
                getCacheGraphics().setColor(Color.gray);
595
                getCacheGraphics().drawRect(0, 0, width-1, height-1);
596

    
597
                mouse = new Point(e.getX(), e.getY());
598
                changePos(e.getX(), e.getY());
599
                autoAdjusted = false;
600
        }
601

    
602
        /*
603
         * (non-Javadoc)
604
         * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
605
         */
606
        public void mouseDragged(MouseEvent e) {
607
                changePos(e.getX(), e.getY());
608
        }
609

    
610
        /*
611
         * (non-Javadoc)
612
         * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
613
         */
614
        public void mouseReleased(MouseEvent e) {
615
                if (mouse != null) {
616
                        x1 = x1 - ((e.getX() - mouse.getX())/zoom);
617
                        y1 = y1 - ((e.getY() - mouse.getY())/zoom);
618
                        updateImageCache(true);
619
                        refreshImage(0, 0);
620
                }
621
                mouse = null;
622
        }
623

    
624
        private void changePos(int x, int y) {
625
                if (mouse != null)
626
                        refreshImage((int) (x - mouse.getX()), (int) (y - mouse.getY()));
627
        }
628

    
629
        /**
630
         * Evento de la rueda del rat?n para hacer Zoom In o Zoom Out en la posici?n
631
         * del puntero.
632
         */
633
        public void mouseWheelMoved(MouseWheelEvent e) {
634
                if (e.getWheelRotation() > 0) {
635
                        ZoomOut(isXInverted() ? this.getWidth() - e.getX() : e.getX(), isYInverted() ? this.getHeight() - e.getY() : e.getY());
636
                        autoAdjusted = false;
637
                }
638
                if (e.getWheelRotation() < 0) {
639
                        ZoomIn(isXInverted() ? this.getWidth() - e.getX() : e.getX(), isYInverted() ? this.getHeight() - e.getY() : e.getY());
640
                        autoAdjusted = false;
641
                }
642
        }
643

    
644
        /**
645
         * Obtener si el eje de las Y esta invertido
646
         * @return
647
         */
648
        private boolean isYInverted() {
649
                return yInverted;
650
        }
651

    
652
        /**
653
         * Obtener si el eje de las X esta invertido
654
         * @return
655
         */
656
        private boolean isXInverted() {
657
                return xInverted;
658
        }
659

    
660
        /*
661
         * (non-Javadoc)
662
         * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
663
         */
664
        public void mouseMoved(MouseEvent e) {
665
                if ((e.getX() > (width - 20)) && (e.getY() < 20)) {
666
                        if (showHelp)
667
                                setToolTipText(Messages.getText("cerrar"));
668
                        else
669
                                setToolTipText(Messages.getText("ayuda"));
670
                        setCursor(new Cursor(Cursor.HAND_CURSOR));
671
                } else {
672
                        setCursor(new Cursor(Cursor.MOVE_CURSOR));
673
                        setToolTipText(null);
674
                }
675
        }
676

    
677
        /*
678
         * (non-Javadoc)
679
         * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
680
         */
681
        public void mouseClicked(MouseEvent e) {
682
                if ((e.getX() > (width - 20)) && (e.getY() < 20)) {
683
                        callShowHelp();
684
                }
685
        }
686

    
687
        public void keyReleased(KeyEvent e) {}
688
        public void keyTyped(KeyEvent e) {}
689
        public void mouseEntered(MouseEvent e) {}
690
        public void mouseExited(MouseEvent e) {}
691

    
692
}