| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3146081 commit 6c91f86
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,50 +26,50 @@ | |||
| 26 | 26 | import javax.swing.*; | |
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | - abstract public class EditorButton extends JComponent | ||
| 29 | + abstract public class EditorButton extends JComponent | ||
| 30 | 30 | implements MouseListener, MouseMotionListener, ActionListener { | |
| 31 | 31 | static public final int DIM = 35; | |
| 32 | 32 | ||
| 33 | - /** Button's description. */ | ||
| 33 | + /** Button's description. */ | ||
| 34 | 34 | protected String title; | |
| 35 | - /** Description of alternate behavior when shift is down. */ | ||
| 35 | + /** Description of alternate behavior when shift is down. */ | ||
| 36 | 36 | protected String titleShift; | |
| 37 | 37 | ||
| 38 | 38 | protected boolean pressed; | |
| 39 | 39 | protected boolean selected; | |
| 40 | 40 | protected boolean rollover; | |
| 41 | 41 | protected JLabel rolloverLabel; | |
| 42 | 42 | protected boolean shift; | |
| 43 | - | ||
| 43 | + | ||
| 44 | 44 | protected Image enabledImage; | |
| 45 | 45 | protected Image disabledImage; | |
| 46 | 46 | protected Image selectedImage; | |
| 47 | 47 | protected Image rolloverImage; | |
| 48 | 48 | protected Image pressedImage; | |
| 49 | - | ||
| 49 | + | ||
| 50 | 50 | protected Image gradient; | |
| 51 | - | ||
| 51 | + | ||
| 52 | 52 | protected Mode mode; | |
| 53 | - | ||
| 54 | - | ||
| 53 | + | ||
| 54 | + | ||
| 55 | 55 | public EditorButton(Mode mode, String name, String title) { | |
| 56 | 56 | this(mode, name, title, title); | |
| 57 | 57 | } | |
| 58 | - | ||
| 58 | + | ||
| 59 | 59 | ||
| 60 | 60 | public EditorButton(Mode mode, String name, String title, String titleShift) { | |
| 61 | 61 | this.mode = mode; | |
| 62 | 62 | this.title = title; | |
| 63 | 63 | this.titleShift = titleShift; | |
| 64 | - | ||
| 64 | + | ||
| 65 | 65 | final int res = Toolkit.highResDisplay() ? 2 : 1; | |
| 66 | 66 | disabledImage = mode.loadImage(name + "-disabled-" + res + "x.png"); | |
| 67 | 67 | enabledImage = mode.loadImage(name + "-enabled-" + res + "x.png"); | |
| 68 | 68 | selectedImage = mode.loadImage(name + "-selected-" + res + "x.png"); | |
| 69 | 69 | pressedImage = mode.loadImage(name + "-pressed-" + res + "x.png"); | |
| 70 | 70 | rolloverImage = mode.loadImage(name + "-rollover-" + res + "x.png"); | |
| 71 | - | ||
| 72 | - if (disabledImage == null) { | ||
| 71 | + | ||
| 72 | + if (disabledImage == null) { | ||
| 73 | 73 | disabledImage = enabledImage; | |
| 74 | 74 | } | |
| 75 | 75 | if (selectedImage == null) { | |
@@ -84,8 +84,8 @@ public EditorButton(Mode mode, String name, String title, String titleShift) { | |||
| 84 | 84 | addMouseListener(this); | |
| 85 | 85 | addMouseMotionListener(this); | |
| 86 | 86 | } | |
| 87 | - | ||
| 88 | - | ||
| 87 | + | ||
| 88 | + | ||
| 89 | 89 | @Override | |
| 90 | 90 | public void paintComponent(Graphics g) { | |
| 91 | 91 | Image image = enabledImage; | |
@@ -103,39 +103,39 @@ public void paintComponent(Graphics g) { | |||
| 103 | 103 | } | |
| 104 | 104 | g.drawImage(image, 0, 0, DIM, DIM, this); | |
| 105 | 105 | } | |
| 106 | - | ||
| 107 | - | ||
| 106 | + | ||
| 107 | + | ||
| 108 | 108 | // public String toString() { | |
| 109 | 109 | // switch (this) { | |
| 110 | 110 | // case DISABLED: return "disabled"; | |
| 111 | 111 | // case ENABLED: return "enabled"; | |
| 112 | 112 | // case SELECTED: return "selected"; | |
| 113 | 113 | // case ROLLOVER: return "rollover"; | |
| 114 | 114 | // case PRESSED: return "pressed"; | |
| 115 | - // | ||
| 115 | + // | ||
| 116 | 116 | //// for (State bs : State.values()) { | |
| 117 | 117 | //// Image image = mode.loadImage(bs.getFilename(name)); | |
| 118 | 118 | //// if (image != null) { | |
| 119 | 119 | //// imageMap.put(bs, image); | |
| 120 | 120 | //// } | |
| 121 | 121 | //// } | |
| 122 | - //// | ||
| 122 | + //// | ||
| 123 | 123 | //// enabled = true; | |
| 124 | 124 | //// //updateState(); | |
| 125 | 125 | //// setState(State.ENABLED); | |
| 126 | - // } | ||
| 127 | - | ||
| 128 | - | ||
| 126 | + // } | ||
| 127 | + | ||
| 128 | + | ||
| 129 | 129 | public void setReverse() { | |
| 130 | 130 | gradient = mode.getGradient("reversed", DIM, DIM); | |
| 131 | 131 | } | |
| 132 | - | ||
| 133 | - | ||
| 132 | + | ||
| 133 | + | ||
| 134 | 134 | // public void setGradient(Image gradient) { | |
| 135 | 135 | // this.gradient = gradient; | |
| 136 | 136 | // } | |
| 137 | - | ||
| 138 | - | ||
| 137 | + | ||
| 138 | + | ||
| 139 | 139 | public void setRolloverLabel(JLabel label) { | |
| 140 | 140 | rolloverLabel = label; | |
| 141 | 141 | } | |
@@ -145,12 +145,12 @@ public void setRolloverLabel(JLabel label) { | |||
| 145 | 145 | public void mouseClicked(MouseEvent e) { | |
| 146 | 146 | if (isEnabled()) { | |
| 147 | 147 | shift = e.isShiftDown(); | |
| 148 | - actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, | ||
| 148 | + actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, | ||
| 149 | 149 | null, e.getModifiers())); | |
| 150 | 150 | } | |
| 151 | 151 | } | |
| 152 | - | ||
| 153 | - | ||
| 152 | + | ||
| 153 | + | ||
| 154 | 154 | public boolean isShiftDown() { | |
| 155 | 155 | return shift; | |
| 156 | 156 | } | |
@@ -166,8 +166,8 @@ public void mousePressed(MouseEvent e) { | |||
| 166 | 166 | public void mouseReleased(MouseEvent e) { | |
| 167 | 167 | setPressed(false); | |
| 168 | 168 | } | |
| 169 | - | ||
| 170 | - | ||
| 169 | + | ||
| 170 | + | ||
| 171 | 171 | public void setPressed(boolean pressed) { | |
| 172 | 172 | if (isEnabled()) { | |
| 173 | 173 | this.pressed = pressed; | |
@@ -176,6 +176,11 @@ public void setPressed(boolean pressed) { | |||
| 176 | 176 | } | |
| 177 | 177 | ||
| 178 | 178 | ||
| 179 | + public void setSelected(boolean selected) { | ||
| 180 | + this.selected = selected; | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + | ||
| 179 | 184 | @Override | |
| 180 | 185 | public void mouseEntered(MouseEvent e) { | |
| 181 | 186 | rollover = true; | |
@@ -205,41 +210,41 @@ public void mouseMoved(MouseEvent e) { } | |||
| 205 | 210 | ||
| 206 | 211 | ||
| 207 | 212 | abstract public void actionPerformed(ActionEvent e); | |
| 208 | - | ||
| 213 | + | ||
| 209 | 214 | // @Override | |
| 210 | - // public void actionPerformed(ActionEvent e) { | ||
| 215 | + // public void actionPerformed(ActionEvent e) { | ||
| 211 | 216 | // // To be overridden by all subclasses | |
| 212 | 217 | // } | |
| 213 | - | ||
| 214 | - | ||
| 218 | + | ||
| 219 | + | ||
| 215 | 220 | @Override | |
| 216 | 221 | public Dimension getPreferredSize() { | |
| 217 | 222 | return new Dimension(DIM, DIM); | |
| 218 | 223 | } | |
| 219 | - | ||
| 220 | - | ||
| 224 | + | ||
| 225 | + | ||
| 221 | 226 | @Override | |
| 222 | 227 | public Dimension getMinimumSize() { | |
| 223 | 228 | return getPreferredSize(); | |
| 224 | 229 | } | |
| 225 | - | ||
| 226 | - | ||
| 230 | + | ||
| 231 | + | ||
| 227 | 232 | @Override | |
| 228 | 233 | public Dimension getMaximumSize() { | |
| 229 | 234 | return getPreferredSize(); | |
| 230 | 235 | } | |
| 231 | - | ||
| 232 | - | ||
| 236 | + | ||
| 237 | + | ||
| 233 | 238 | // public Image getImage() { | |
| 234 | 239 | // return imageMap.get(state); | |
| 235 | 240 | // } | |
| 236 | 241 | // | |
| 237 | - // | ||
| 242 | + // | ||
| 238 | 243 | //// protected void updateState() { | |
| 239 | 244 | //// state = ButtonState.ENABLED; | |
| 240 | 245 | //// } | |
| 241 | - // | ||
| 242 | - // | ||
| 246 | + // | ||
| 247 | + // | ||
| 243 | 248 | // public void setEnabled(boolean enabled) { | |
| 244 | 249 | // this.enabled = enabled; | |
| 245 | 250 | // if (enabled) { | |
@@ -252,25 +257,25 @@ public Dimension getMaximumSize() { | |||
| 252 | 257 | // } | |
| 253 | 258 | // } | |
| 254 | 259 | // } | |
| 255 | - // | ||
| 256 | - // | ||
| 260 | + // | ||
| 261 | + // | ||
| 257 | 262 | // public void setState(State state) { | |
| 258 | 263 | // this.state = state; | |
| 259 | 264 | // } | |
| 260 | 265 | ||
| 261 | 266 | ||
| 262 | 267 | // public enum State { | |
| 263 | 268 | // DISABLED, ENABLED, SELECTED, ROLLOVER, PRESSED; | |
| 264 | - // | ||
| 265 | - // /** | ||
| 266 | - // * @param name the root name | ||
| 269 | + // | ||
| 270 | + // /** | ||
| 271 | + // * @param name the root name | ||
| 267 | 272 | // * @return | |
| 268 | 273 | // */ | |
| 269 | 274 | // public String getFilename(String name) { | |
| 270 | 275 | // final int res = Toolkit.highResDisplay() ? 2 : 1; | |
| 271 | - // return name + "-" + toString() + "-" + res + "x.png"; | ||
| 276 | + // return name + "-" + toString() + "-" + res + "x.png"; | ||
| 272 | 277 | // } | |
| 273 | - // | ||
| 278 | + // | ||
| 274 | 279 | // public String toString() { | |
| 275 | 280 | // switch (this) { | |
| 276 | 281 | // case DISABLED: return "disabled"; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments