[Polycasso-commit] SF.net SVN: polycasso:[91] trunk/polycasso/src/com/mebigfatguy/polycasso/ Settin
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2009-11-28 23:20:48
|
Revision: 91
http://polycasso.svn.sourceforge.net/polycasso/?rev=91&view=rev
Author: dbrosius
Date: 2009-11-28 23:20:40 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
a dialog for configuring settings
Added Paths:
-----------
trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java 2009-11-28 23:20:40 UTC (rev 91)
@@ -0,0 +1,152 @@
+/*
+ * polycasso - Cubism Artwork generator
+ * Copyright 2009 MeBigFatGuy.com
+ * Copyright 2009 Dave Brosius
+ * Inspired by work by Roger Alsing
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package com.mebigfatguy.polycasso;
+
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import com.jgoodies.forms.layout.CellConstraints;
+import com.jgoodies.forms.layout.FormLayout;
+
+public class SettingsDialog extends JDialog {
+
+ Settings dlgSettings;
+ private JButton okButton;
+ private JButton cancelButton;
+ private JTextField widthField;
+ private JTextField heightField;
+ private JTextField maxPolygonField;
+ private JTextField maxPtMoveField;
+ private boolean isOK;
+
+ public SettingsDialog(Settings settings) {
+ setTitle(PolycassoBundle.getString(PolycassoBundle.Key.Settings));
+ dlgSettings = (Settings)settings.clone();
+ initComponents();
+ initListeners();
+ isOK = false;
+ }
+
+ public boolean isOK() {
+ return false;
+ }
+
+ public Settings getSettings() {
+ return dlgSettings;
+ }
+
+ private void initComponents() {
+ Container cp = getContentPane();
+ cp.setLayout(new BorderLayout(4, 4));
+
+ cp.add(createOptionsPanel(), BorderLayout.CENTER);
+ cp.add(createControlPanel(), BorderLayout.SOUTH);
+ pack();
+ }
+
+ private JPanel createOptionsPanel() {
+ JPanel optPanel = new JPanel();
+ optPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ optPanel.setLayout(new FormLayout("pref, 3dlu, 100px, 5dlu, pref, 3dlu, 100px", "pref, 1dlu, pref, 15dlu, pref, 1dlu, pref"));
+ CellConstraints cc = new CellConstraints();
+
+ JLabel maxSizeLabel = new JLabel(PolycassoBundle.getString(PolycassoBundle.Key.MaxImageSize));
+ optPanel.add(maxSizeLabel, cc.xyw(1, 1, 7));
+
+ JLabel widthLabel = new JLabel(PolycassoBundle.getString(PolycassoBundle.Key.Width));
+ optPanel.add(widthLabel, cc.xy(1, 3));
+ widthField = new JTextField(4);
+ widthField.setDocument(new IntegerDocument());
+ widthLabel.setLabelFor(widthField);
+ widthField.setText(String.valueOf(dlgSettings.getMaxImageSize().width));
+ optPanel.add(widthField, cc.xy(3, 3));
+
+ JLabel heightLabel = new JLabel(PolycassoBundle.getString(PolycassoBundle.Key.Height));
+ optPanel.add(heightLabel, cc.xy(5, 3));
+ heightField = new JTextField(4);
+ heightField.setDocument(new IntegerDocument());
+ heightLabel.setLabelFor(heightField);
+ heightField.setText(String.valueOf(dlgSettings.getMaxImageSize().height));
+ optPanel.add(heightField, cc.xy(7, 3));
+
+ JLabel maxPolyLabel = new JLabel(PolycassoBundle.getString(PolycassoBundle.Key.MaximumPolygons));
+ optPanel.add(maxPolyLabel, cc.xyw(1, 5, 5));
+ maxPolygonField = new JTextField(4);
+ maxPolygonField.setDocument(new IntegerDocument());
+ maxPolyLabel.setLabelFor(maxPolygonField);
+ maxPolygonField.setText(String.valueOf(dlgSettings.getMaxPolygons()));
+ optPanel.add(maxPolygonField, cc.xy(7, 5));
+
+ JLabel maxPtMoveLabel = new JLabel(PolycassoBundle.getString(PolycassoBundle.Key.MaximumPointMovement));
+ optPanel.add(maxPtMoveLabel, cc.xyw(1, 7, 5));
+ maxPtMoveField = new JTextField(4);
+ maxPtMoveField.setDocument(new IntegerDocument());
+ maxPtMoveLabel.setLabelFor(maxPtMoveField);
+ maxPtMoveField.setText(String.valueOf(dlgSettings.getMaxPtMovement()));
+ optPanel.add(maxPtMoveField, cc.xy(7, 7));
+ return optPanel;
+ }
+
+ private JPanel createControlPanel() {
+ JPanel ctrlPanel = new JPanel();
+ ctrlPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.X_AXIS));
+ ctrlPanel.add(Box.createHorizontalGlue());
+
+ okButton = new JButton(PolycassoBundle.getString(PolycassoBundle.Key.OK));
+ cancelButton = new JButton(PolycassoBundle.getString(PolycassoBundle.Key.Cancel));
+
+ ctrlPanel.add(okButton);
+ ctrlPanel.add(Box.createHorizontalStrut(10));
+ ctrlPanel.add(cancelButton);
+ ctrlPanel.add(Box.createHorizontalStrut(10));
+ return ctrlPanel;
+ }
+
+ private void initListeners() {
+ okButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ isOK = true;
+ dispose();
+ }
+ });
+
+ cancelButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ isOK = false;
+ dispose();
+ }
+ });
+ }
+
+
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|