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

Last change on this file since 3094 was 3094, checked in by Gubaer, 14 years ago

Improved widget for selecting a bounding box based on a grid of OSM tiles (see Haiti Lessons Learned).
Also moving the various widgets for selecting a bounding box into a new package org.openstreetmap.josm.gui.bbox. Going to need them shortly in the Changeset Query Dialog and in an upcoming XAPI plugin.

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
1// License: GPL. Copyright 2007 by Tim Haussmann
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 hit(Point point){
43 if(x < point.x && point.x < x + enlargeImage.getIconWidth()){
44 if(y < point.y && point.y < y + enlargeImage.getIconHeight() ){
45 return true;
46 }
47 }
48 return false;
49 }
50
51}
Note: See TracBrowser for help on using the repository browser.