source: josm/trunk/src/org/openstreetmap/josm/gui/bbox/SizeButton.java@ 6380

Last change on this file since 6380 was 6380, checked in by Don-vip, 10 years ago

update license/copyright information

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.bbox;
3
4import java.awt.Graphics;
5import java.awt.Point;
6
7import javax.swing.ImageIcon;
8
9import org.openstreetmap.josm.tools.ImageProvider;
10
11/**
12 * @author Tim Haussmann
13 */
14public class SizeButton{
15
16 private int x = 0;
17 private int y = 0;
18
19 private ImageIcon enlargeImage;
20 private ImageIcon shrinkImage;
21 private boolean isEnlarged = false;
22
23 public SizeButton(){
24 enlargeImage = ImageProvider.get("view-fullscreen.png");
25 shrinkImage = ImageProvider.get("view-fullscreen-revert.png");
26 }
27
28 public void paint(Graphics g) {
29 if(isEnlarged) {
30 if(shrinkImage != null)
31 g.drawImage(shrinkImage.getImage(),x,y, null);
32 } else {
33 if(enlargeImage != null)
34 g.drawImage(enlargeImage.getImage(),x,y, null);
35 }
36 }
37
38 public void toggle() {
39 isEnlarged = !isEnlarged;
40 }
41
42 public boolean isEnlarged() {
43 return isEnlarged;
44 }
45
46 public boolean hit(Point point) {
47 if(x < point.x && point.x < x + enlargeImage.getIconWidth()) {
48 if(y < point.y && point.y < y + enlargeImage.getIconHeight()) {
49 return true;
50 }
51 }
52 return false;
53 }
54
55}
Note: See TracBrowser for help on using the repository browser.