auto import from //depot/cupcake/@136594

This commit is contained in:
The Android Open Source Project
2009-03-05 14:34:30 -08:00
parent 52d4c30ca5
commit edd86fdaa9
24 changed files with 596 additions and 148 deletions

View File

@@ -40,11 +40,12 @@ public class Application {
}
}
public static void main(String... args) {
public static void main(final String... args) {
initUserInterface();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
MainFrame frame = new MainFrame();
String arg = args.length > 0 ? args[0] : null;
MainFrame frame = new MainFrame(arg);
frame.setDefaultCloseOperation(MainFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);

View File

@@ -651,6 +651,7 @@ class ImageEditorPanel extends JPanel {
private int lastPositionX;
private int lastPositionY;
private int currentButton;
private boolean showCursor;
private JLabel helpLabel;
@@ -687,16 +688,20 @@ class ImageEditorPanel extends JPanel {
addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent event) {
paint(event.getX(), event.getY(), event.isShiftDown() ? MouseEvent.BUTTON3 :
event.getButton());
// Store the button here instead of retrieving it again in MouseDragged
// below, because on linux, calling MouseEvent.getButton() for the drag
// event returns 0, which appears to be technically correct (no button
// changed state).
currentButton = event.isShiftDown() ? MouseEvent.BUTTON3 : event.getButton();
paint(event.getX(), event.getY(), currentButton);
}
});
addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(MouseEvent event) {
if (!checkLockedRegion(event.getX(), event.getY())) {
paint(event.getX(), event.getY(), event.isShiftDown() ? MouseEvent.BUTTON3 :
event.getButton());
// use the stored button, see note above
paint(event.getX(), event.getY(), currentButton);
}
}

View File

@@ -40,14 +40,24 @@ public class MainFrame extends JFrame {
private JMenuItem saveMenuItem;
private ImageEditorPanel imageEditor;
public MainFrame() throws HeadlessException {
public MainFrame(String path) throws HeadlessException {
super("Draw 9-patch");
buildActions();
buildMenuBar();
buildContent();
showOpenFilePanel();
if (path == null) {
showOpenFilePanel();
} else {
try {
File file = new File(path);
BufferedImage img = GraphicsUtilities.loadCompatibleImage(file.toURI().toURL());
showImageEditor(img, file.getAbsolutePath());
} catch (Exception ex) {
showOpenFilePanel();
}
}
// pack();
setSize(1024, 600);