Skip to content
Permalink
Browse files

LOTS OF WORK on canvas. New icon. new greeting. Renamed project. Started

wokr on global color choosing.
  • Loading branch information...
Dakkra committed Jun 8, 2015
1 parent 5319600 commit 9dd666c9d49a64685b5bb84dbc85f90f3c4f1c8e
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PyxleOS::E</name>
<name>PyxleOS</name>
<comment></comment>
<projects>
</projects>
@@ -3,22 +3,22 @@
import java.awt.Color;

public class ColorReference {
private Color fgColor = new Color(0, 0, 0);
private Color bgColor = new Color(255, 255, 255);
private static Color fgColor = new Color(0, 0, 0);
private static Color bgColor = Color.BLUE;

public Color getfgColor() {
public static Color getFgColor() {
return fgColor;
}

public void setfgColor(Color color) {
fgColor = color;
public static void setFgColor(Color fgColor) {
ColorReference.fgColor = fgColor;
}

public Color getbgColor() {
public static Color getBgColor() {
return bgColor;
}

public void setbgColor(Color color) {
bgColor = color;
public static void setBgColor(Color bgColor) {
ColorReference.bgColor = bgColor;
}
}
@@ -10,13 +10,11 @@

public class PyxleOS {
public static void main(String[] args) {
System.out.println("Initializing PyxleOS::E");

ColorReference cr = new ColorReference();
System.out.println("Initializing PyxleOS");

UISettings uis = new UISettings();

MainWindow mw = new MainWindow(uis, cr);
MainWindow mw = new MainWindow(uis);

mw.setUIS();
mw.cnsUI();
@@ -2,17 +2,31 @@

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFileChooser;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.KeyStroke;

import com.dakkra.pyxleos.modules.Module;
import com.dakkra.pyxleos.ui.MainWindow;
import com.sun.glass.events.KeyEvent;

public class Canvas extends Module {

private MainWindow mw;

private DrawPane drawPane;

public Canvas(MainWindow mw) {
this.mw = mw;
makeUI();
@@ -21,13 +35,37 @@ public Canvas(MainWindow mw) {
private void makeUI() {
frame.setTitle("Canvas");

JMenuItem fileSave = new JMenuItem("Save");
fileSave.addActionListener(new SaveEar());
fileSave.setMnemonic(KeyEvent.VK_S);
fileSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
ActionEvent.CTRL_MASK));

JMenuItem fileExport = new JMenuItem("Export");
fileExport.addActionListener(new ExportEar());
fileExport.setMnemonic(KeyEvent.VK_E);
fileExport.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,
ActionEvent.CTRL_MASK));

fileMenu.add(fileSave);
fileMenu.add(fileExport);
fileMenu.add(fileExit);

JMenu editMenu = new JMenu(" Edit ");
JMenuItem editClear = new JMenuItem("Clear");
editClear.addActionListener(new ClearEar());
editClear.setMnemonic(KeyEvent.VK_N);
editClear.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,
ActionEvent.CTRL_MASK));
editMenu.add(editClear);

menuBar.add(editMenu);

JPanel container = new JPanel();
container.setLayout(new BorderLayout());
container.setBackground(Color.DARK_GRAY);

DrawPane drawPane = new DrawPane();
drawPane = new DrawPane(new Dimension(16, 16));

JScrollPane pane = new JScrollPane(drawPane);

@@ -38,4 +76,58 @@ private void makeUI() {
mw.addIFrame(frame);
}

private class ClearEar implements ActionListener {

@Override
public void actionPerformed(ActionEvent e) {
drawPane.clear();
}

}

private class SaveEar implements ActionListener {

@Override
public void actionPerformed(ActionEvent e) {
JFileChooser oChooser = new JFileChooser();
int returnVal = oChooser.showSaveDialog(frame);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File oFile = oChooser.getSelectedFile();
System.out.println(oFile.getAbsolutePath());
BufferedImage img = drawPane.getImage();

try {
ImageIO.write(img, "png", oFile);
} catch (IOException e1) {
e1.printStackTrace();
}
} else {
return;
}
}

}

private class ExportEar implements ActionListener {

@Override
public void actionPerformed(ActionEvent e) {
JFileChooser oChooser = new JFileChooser();
int returnVal = oChooser.showSaveDialog(frame);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File oFile = oChooser.getSelectedFile();
System.out.println(oFile.getAbsolutePath());
BufferedImage img = drawPane.getScaledImage(10);

try {
ImageIO.write(img, "png", oFile);
} catch (IOException e1) {
e1.printStackTrace();
}
} else {
return;
}
}
}

}

0 comments on commit 9dd666c

Please sign in to comment.
You can’t perform that action at this time.