| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,24 @@ | |||
| 1 | + package processing.app; | ||
| 2 | + | ||
| 3 | + import java.io.File; | ||
| 4 | + | ||
| 5 | + import processing.app.ui.SplashWindow; | ||
| 6 | + import processing.app.ui.Toolkit; | ||
| 7 | + | ||
| 8 | + | ||
| 9 | + public class BaseSplash { | ||
| 10 | + static public void main(String[] args) { | ||
| 11 | + try { | ||
| 12 | + final boolean hidpi = Toolkit.highResDisplay(); | ||
| 13 | + final String filename = "lib/about-" + (hidpi ? 2 : 1) + "x.png"; | ||
| 14 | + File splashFile = Platform.getContentFile(filename); | ||
| 15 | + SplashWindow.splash(splashFile.toURI().toURL(), hidpi); | ||
| 16 | + SplashWindow.invokeMain("processing.app.Base", args); | ||
| 17 | + SplashWindow.disposeSplash(); | ||
| 18 | + } catch (Exception e) { | ||
| 19 | + e.printStackTrace(); | ||
| 20 | + // !@#!@$$! umm | ||
| 21 | + //SplashWindow.invokeMain("processing.app.Base", args); | ||
| 22 | + } | ||
| 23 | + } | ||
| 24 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -212,6 +212,14 @@ static public String pluralize(String key, int count) { | |||
| 212 | 212 | } | |
| 213 | 213 | ||
| 214 | 214 | ||
| 215 | + /** | ||
| 216 | + * @param which either yes, no, cancel, ok, or browse | ||
| 217 | + */ | ||
| 218 | + static public String getPrompt(String which) { | ||
| 219 | + return Language.text("prompt." + which); | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + | ||
| 215 | 223 | /** Get all available languages */ | |
| 216 | 224 | static public Map<String, String> getLanguages() { | |
| 217 | 225 | return init().languages; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -401,8 +401,8 @@ public void keyTyped(KeyEvent event) { | |||
| 401 | 401 | JOptionPane.OK_CANCEL_OPTION, | |
| 402 | 402 | JOptionPane.PLAIN_MESSAGE, | |
| 403 | 403 | null, new Object[] { | |
| 404 | - Toolkit.PROMPT_OK, | ||
| 405 | - Toolkit.PROMPT_CANCEL }, | ||
| 404 | + Language.getPrompt("ok"), | ||
| 405 | + Language.getPrompt("cancel") }, | ||
| 406 | 406 | field); | |
| 407 | 407 | ||
| 408 | 408 | if (userReply == JOptionPane.OK_OPTION) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,28 +23,31 @@ | |||
| 23 | 23 | package processing.app.ui; | |
| 24 | 24 | ||
| 25 | 25 | import java.awt.Color; | |
| 26 | - import java.awt.Dimension; | ||
| 27 | 26 | import java.awt.Font; | |
| 28 | 27 | import java.awt.Frame; | |
| 29 | 28 | import java.awt.Graphics; | |
| 30 | - import java.awt.Graphics2D; | ||
| 31 | - import java.awt.Image; | ||
| 32 | - import java.awt.RenderingHints; | ||
| 33 | 29 | import java.awt.Window; | |
| 34 | 30 | import java.awt.event.MouseAdapter; | |
| 35 | 31 | import java.awt.event.MouseEvent; | |
| 36 | 32 | ||
| 33 | + import javax.swing.ImageIcon; | ||
| 34 | + | ||
| 37 | 35 | import processing.app.Base; | |
| 38 | 36 | ||
| 39 | 37 | ||
| 40 | 38 | public class About extends Window { | |
| 41 | - Image image; | ||
| 39 | + ImageIcon icon; | ||
| 42 | 40 | int width, height; | |
| 43 | 41 | ||
| 44 | 42 | ||
| 45 | 43 | public About(Frame frame) { | |
| 46 | 44 | super(frame); | |
| 47 | 45 | ||
| 46 | + icon = Toolkit.getLibIconX("about"); | ||
| 47 | + width = icon.getIconWidth(); | ||
| 48 | + height = icon.getIconHeight(); | ||
| 49 | + | ||
| 50 | + /* | ||
| 48 | 51 | if (Toolkit.highResDisplay()) { | |
| 49 | 52 | image = Toolkit.getLibImage("about-2x.jpg"); //$NON-NLS-1$ | |
| 50 | 53 | width = image.getWidth(null) / 2; | |
@@ -54,28 +57,31 @@ public About(Frame frame) { | |||
| 54 | 57 | width = image.getWidth(null); | |
| 55 | 58 | height = image.getHeight(null); | |
| 56 | 59 | } | |
| 60 | + */ | ||
| 57 | 61 | ||
| 58 | 62 | addMouseListener(new MouseAdapter() { | |
| 59 | 63 | public void mousePressed(MouseEvent e) { | |
| 60 | 64 | dispose(); | |
| 61 | 65 | } | |
| 62 | 66 | }); | |
| 63 | 67 | ||
| 64 | - Dimension screen = Toolkit.getScreenSize(); | ||
| 65 | - setBounds((screen.width-width)/2, (screen.height-height)/2, width, height); | ||
| 68 | + // Dimension screen = Toolkit.getScreenSize(); | ||
| 69 | + // setBounds((screen.width-width)/2, (screen.height-height)/2, width, height); | ||
| 70 | + setLocationRelativeTo(null); | ||
| 66 | 71 | setVisible(true); | |
| 67 | 72 | } | |
| 68 | 73 | ||
| 69 | 74 | ||
| 70 | 75 | public void paint(Graphics g) { | |
| 71 | - g.drawImage(image, 0, 0, width, height, null); | ||
| 76 | + g.drawImage(icon.getImage(), 0, 0, width, height, null); | ||
| 72 | 77 | ||
| 73 | - Graphics2D g2 = (Graphics2D) g; | ||
| 74 | - g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, | ||
| 75 | - RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); | ||
| 78 | + // Graphics2D g2 = (Graphics2D) g; | ||
| 79 | + // g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, | ||
| 80 | + // RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); | ||
| 76 | 81 | ||
| 77 | - g.setFont(new Font("SansSerif", Font.PLAIN, 10)); //$NON-NLS-1$ | ||
| 82 | + g.setFont(Toolkit.getSansFont(Font.PLAIN, 10)); | ||
| 83 | + //g.setFont(new Font("SansSerif", Font.PLAIN, 10)); //$NON-NLS-1$ | ||
| 78 | 84 | g.setColor(Color.white); | |
| 79 | - g.drawString(Base.getVersionName(), 90, 29); | ||
| 85 | + g.drawString(Base.getVersionName(), 26, 29); | ||
| 80 | 86 | } | |
| 81 | 87 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,6 +31,7 @@ | |||
| 31 | 31 | import javax.swing.plaf.basic.BasicSplitPaneDivider; | |
| 32 | 32 | import javax.swing.plaf.basic.BasicSplitPaneUI; | |
| 33 | 33 | ||
| 34 | + import processing.app.Language; | ||
| 34 | 35 | import processing.app.Mode; | |
| 35 | 36 | import processing.app.Platform; | |
| 36 | 37 | import processing.core.PApplet; | |
@@ -265,7 +266,7 @@ public void paint(Graphics screen) { | |||
| 265 | 266 | if (indeterminate) { | |
| 266 | 267 | //int x = cancelButton.getX(); | |
| 267 | 268 | //int w = cancelButton.getWidth(); | |
| 268 | - int w = Toolkit.BUTTON_WIDTH; | ||
| 269 | + int w = Toolkit.getButtonWidth(); | ||
| 269 | 270 | int x = getWidth() - RIGHT_MARGIN - w; | |
| 270 | 271 | int y = getHeight() / 3; | |
| 271 | 272 | int h = getHeight() / 3; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -109,7 +109,7 @@ public PreferencesFrame(Base base) { | |||
| 109 | 109 | ||
| 110 | 110 | sketchbookLocationField = new JTextField(40); | |
| 111 | 111 | ||
| 112 | - browseButton = new JButton(Toolkit.PROMPT_BROWSE); | ||
| 112 | + browseButton = new JButton(Language.getPrompt("browse")); | ||
| 113 | 113 | browseButton.addActionListener(new ActionListener() { | |
| 114 | 114 | public void actionPerformed(ActionEvent e) { | |
| 115 | 115 | File dflt = new File(sketchbookLocationField.getText()); | |
@@ -362,21 +362,22 @@ public void mouseExited(MouseEvent e) { | |||
| 362 | 362 | ||
| 363 | 363 | // [ OK ] [ Cancel ] | |
| 364 | 364 | ||
| 365 | - okButton = new JButton(Toolkit.PROMPT_OK); | ||
| 365 | + okButton = new JButton(Language.getPrompt("ok")); | ||
| 366 | 366 | okButton.addActionListener(new ActionListener() { | |
| 367 | 367 | public void actionPerformed(ActionEvent e) { | |
| 368 | 368 | applyFrame(); | |
| 369 | 369 | disposeFrame(); | |
| 370 | 370 | } | |
| 371 | 371 | }); | |
| 372 | 372 | ||
| 373 | - JButton cancelButton = new JButton(Toolkit.PROMPT_CANCEL); | ||
| 373 | + JButton cancelButton = new JButton(Language.getPrompt("cancel")); | ||
| 374 | 374 | cancelButton.addActionListener(new ActionListener() { | |
| 375 | 375 | public void actionPerformed(ActionEvent e) { | |
| 376 | 376 | disposeFrame(); | |
| 377 | 377 | } | |
| 378 | 378 | }); | |
| 379 | 379 | ||
| 380 | + final int buttonWidth = Toolkit.getButtonWidth(); | ||
| 380 | 381 | layout.setHorizontalGroup(layout.createSequentialGroup() // sequential group for border + mainContent + border | |
| 381 | 382 | .addGap(BORDER) | |
| 382 | 383 | .addGroup(layout.createParallelGroup() // parallel group for rest of the components | |
@@ -431,8 +432,8 @@ public void actionPerformed(ActionEvent e) { | |||
| 431 | 432 | .addComponent(preferencePathLabel) | |
| 432 | 433 | .addComponent(preferenceHintLabel) | |
| 433 | 434 | .addGroup(GroupLayout.Alignment.TRAILING,layout.createSequentialGroup() // Trailing so that the buttons are to the right | |
| 434 | - .addComponent(okButton, Toolkit.BUTTON_WIDTH, GroupLayout.DEFAULT_SIZE, Toolkit.BUTTON_WIDTH) // Ok and Cancel buttton are now of size BUTTON_WIDTH | ||
| 435 | - .addComponent(cancelButton, Toolkit.BUTTON_WIDTH, GroupLayout.DEFAULT_SIZE, Toolkit.BUTTON_WIDTH) | ||
| 435 | + .addComponent(okButton, buttonWidth, GroupLayout.DEFAULT_SIZE, buttonWidth) // Ok and Cancel buttton are now of size BUTTON_WIDTH | ||
| 436 | + .addComponent(cancelButton, buttonWidth, GroupLayout.DEFAULT_SIZE, buttonWidth) | ||
| 436 | 437 | )) | |
| 437 | 438 | .addGap(BORDER) | |
| 438 | 439 | ); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,5 @@ | |||
| 1 | + package processing.app.ui; | ||
| 2 | + | ||
| 1 | 3 | /* | |
| 2 | 4 | * @(#)SplashWindow.java 2.2.1 2006-05-27 | |
| 3 | 5 | * | |
@@ -9,10 +11,16 @@ | |||
| 9 | 11 | * without having to attribute to Werner Randelshofer. | |
| 10 | 12 | */ | |
| 11 | 13 | ||
| 12 | - import java.awt.*; | ||
| 13 | - import java.awt.event.*; | ||
| 14 | - import java.net.*; | ||
| 15 | - import java.io.*; | ||
| 14 | + import java.awt.EventQueue; | ||
| 15 | + import java.awt.Frame; | ||
| 16 | + import java.awt.Graphics; | ||
| 17 | + import java.awt.Image; | ||
| 18 | + import java.awt.MediaTracker; | ||
| 19 | + import java.awt.Toolkit; | ||
| 20 | + import java.awt.Window; | ||
| 21 | + import java.awt.event.MouseAdapter; | ||
| 22 | + import java.awt.event.MouseEvent; | ||
| 23 | + import java.net.URL; | ||
| 16 | 24 | ||
| 17 | 25 | /** | |
| 18 | 26 | * A Splash window. | |
@@ -42,12 +50,12 @@ public class SplashWindow extends Window { | |||
| 42 | 50 | * (Singleton design pattern). | |
| 43 | 51 | */ | |
| 44 | 52 | private static SplashWindow instance; | |
| 45 | - | ||
| 53 | + | ||
| 46 | 54 | /** | |
| 47 | 55 | * The splash image which is displayed on the splash window. | |
| 48 | 56 | */ | |
| 49 | 57 | private Image image; | |
| 50 | - | ||
| 58 | + | ||
| 51 | 59 | /** | |
| 52 | 60 | * This attribute indicates whether the method | |
| 53 | 61 | * paint(Graphics) has been called at least once since the | |
@@ -62,23 +70,23 @@ public class SplashWindow extends Window { | |||
| 62 | 70 | * @see #splash | |
| 63 | 71 | */ | |
| 64 | 72 | private boolean paintCalled = false; | |
| 65 | - | ||
| 73 | + | ||
| 66 | 74 | /** | |
| 67 | 75 | * Creates a new instance. | |
| 68 | 76 | * @param parent the parent of the window. | |
| 69 | 77 | * @param image the splash image. | |
| 70 | 78 | */ | |
| 71 | - private SplashWindow(Frame parent, Image image) { | ||
| 79 | + private SplashWindow(Frame parent, Image image, boolean hidpi) { | ||
| 72 | 80 | super(parent); | |
| 73 | 81 | this.image = image; | |
| 74 | - | ||
| 82 | + | ||
| 75 | 83 | // Load the image | |
| 76 | 84 | MediaTracker mt = new MediaTracker(this); | |
| 77 | 85 | mt.addImage(image,0); | |
| 78 | 86 | try { | |
| 79 | 87 | mt.waitForID(0); | |
| 80 | 88 | } catch(InterruptedException ie){} | |
| 81 | - | ||
| 89 | + | ||
| 82 | 90 | // Abort on failure | |
| 83 | 91 | if (mt.isErrorID(0)) { | |
| 84 | 92 | setSize(0,0); | |
@@ -89,17 +97,21 @@ private SplashWindow(Frame parent, Image image) { | |||
| 89 | 97 | } | |
| 90 | 98 | return; | |
| 91 | 99 | } | |
| 92 | - | ||
| 100 | + | ||
| 93 | 101 | // Center the window on the screen | |
| 94 | 102 | int imgWidth = image.getWidth(this); | |
| 95 | 103 | int imgHeight = image.getHeight(this); | |
| 104 | + | ||
| 105 | + if (hidpi) { | ||
| 106 | + imgWidth /= 2; | ||
| 107 | + imgHeight /= 2; | ||
| 108 | + } | ||
| 96 | 109 | setSize(imgWidth, imgHeight); | |
| 97 | - Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); | ||
| 98 | - setLocation( | ||
| 99 | - (screenDim.width - imgWidth) / 2, | ||
| 100 | - (screenDim.height - imgHeight) / 2 | ||
| 101 | - ); | ||
| 102 | - | ||
| 110 | + // Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); | ||
| 111 | + // setLocation((screenDim.width - imgWidth) / 2, | ||
| 112 | + // (screenDim.height - imgHeight) / 2); | ||
| 113 | + setLocationRelativeTo(null); | ||
| 114 | + | ||
| 103 | 115 | // Users shall be able to close the splash window by | |
| 104 | 116 | // clicking on its display area. This mouse listener | |
| 105 | 117 | // listens for mouse clicks and disposes the splash window. | |
@@ -119,7 +131,7 @@ public void mouseClicked(MouseEvent evt) { | |||
| 119 | 131 | }; | |
| 120 | 132 | addMouseListener(disposeOnClick); | |
| 121 | 133 | } | |
| 122 | - | ||
| 134 | + | ||
| 123 | 135 | /** | |
| 124 | 136 | * Updates the display area of the window. | |
| 125 | 137 | */ | |
@@ -134,8 +146,8 @@ public void update(Graphics g) { | |||
| 134 | 146 | * Paints the image on the window. | |
| 135 | 147 | */ | |
| 136 | 148 | public void paint(Graphics g) { | |
| 137 | - g.drawImage(image, 0, 0, this); | ||
| 138 | - | ||
| 149 | + g.drawImage(image, 0, 0, getWidth(), getHeight(), this); | ||
| 150 | + | ||
| 139 | 151 | // Notify method splash that the window | |
| 140 | 152 | // has been painted. | |
| 141 | 153 | // Note: To improve performance we do not enter | |
@@ -145,21 +157,21 @@ public void paint(Graphics g) { | |||
| 145 | 157 | synchronized (this) { notifyAll(); } | |
| 146 | 158 | } | |
| 147 | 159 | } | |
| 148 | - | ||
| 160 | + | ||
| 149 | 161 | /** | |
| 150 | 162 | * Open's a splash window using the specified image. | |
| 151 | 163 | * @param image The splash image. | |
| 152 | 164 | */ | |
| 153 | - public static void splash(Image image) { | ||
| 165 | + public static void splash(Image image, boolean hidpi) { | ||
| 154 | 166 | if (instance == null && image != null) { | |
| 155 | 167 | Frame f = new Frame(); | |
| 156 | - | ||
| 168 | + | ||
| 157 | 169 | // Create the splash image | |
| 158 | - instance = new SplashWindow(f, image); | ||
| 159 | - | ||
| 170 | + instance = new SplashWindow(f, image, hidpi); | ||
| 171 | + | ||
| 160 | 172 | // Show the window. | |
| 161 | - instance.show(); | ||
| 162 | - | ||
| 173 | + instance.setVisible(true); | ||
| 174 | + | ||
| 163 | 175 | // Note: To make sure the user gets a chance to see the | |
| 164 | 176 | // splash window we wait until its paint method has been | |
| 165 | 177 | // called at least once by the AWT event dispatcher thread. | |
@@ -175,16 +187,17 @@ public static void splash(Image image) { | |||
| 175 | 187 | } | |
| 176 | 188 | } | |
| 177 | 189 | } | |
| 190 | + | ||
| 178 | 191 | /** | |
| 179 | 192 | * Open's a splash window using the specified image. | |
| 180 | 193 | * @param imageURL The url of the splash image. | |
| 181 | 194 | */ | |
| 182 | - public static void splash(URL imageURL) { | ||
| 195 | + public static void splash(URL imageURL, boolean hidpi) { | ||
| 183 | 196 | if (imageURL != null) { | |
| 184 | - splash(Toolkit.getDefaultToolkit().createImage(imageURL)); | ||
| 197 | + splash(Toolkit.getDefaultToolkit().createImage(imageURL), hidpi); | ||
| 185 | 198 | } | |
| 186 | 199 | } | |
| 187 | - | ||
| 200 | + | ||
| 188 | 201 | /** | |
| 189 | 202 | * Closes the splash window. | |
| 190 | 203 | */ | |
@@ -194,7 +207,7 @@ public static void disposeSplash() { | |||
| 194 | 207 | instance = null; | |
| 195 | 208 | } | |
| 196 | 209 | } | |
| 197 | - | ||
| 210 | + | ||
| 198 | 211 | /** | |
| 199 | 212 | * Invokes the main method of the provided class name. | |
| 200 | 213 | * @param args the command line arguments | |
| Back | FazBrowse Home | New Git URL |
0 commit comments