/** * This file is part of VisiCut. * Copyright (C) 2011 - 2013 Thomas Oster <thomas.oster@rwth-aachen.de> * RWTH Aachen University - 52062 Aachen, Germany * * VisiCut is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * VisiCut is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with VisiCut. If not, see <http://www.gnu.org/licenses/>. **/ /* * EditRasterProfileDialog.java * * Created on 06.09.2011, 10:34:59 */ package com.t_oster.visicut.gui; import com.t_oster.visicut.VisicutModel; import com.t_oster.visicut.model.Raster3dProfile; /** * * @author Thomas Oster <thomas.oster@rwth-aachen.de> */ public class EditRaster3dProfileDialog extends javax.swing.JDialog { protected Raster3dProfile rasterProfile = null; public static final String PROP_RASTERPROFILE = "rasterProfile"; /** * Get the value of RasterProfile * * @return the value of RasterProfile */ public Raster3dProfile getRasterProfile() { return rasterProfile; } /** * Set the value of RasterProfile * * @param rasterProfile new value of RasterProfile */ public void setRasterProfile(Raster3dProfile rasterProfile) { Raster3dProfile oldRasterProfile = this.rasterProfile; this.rasterProfile = rasterProfile; firePropertyChange(PROP_RASTERPROFILE, oldRasterProfile, rasterProfile); if (rasterProfile == null) { this.setCurrentRasterProfile(new Raster3dProfile()); } else { this.setCurrentRasterProfile((Raster3dProfile) rasterProfile.clone()); } } protected Raster3dProfile currentRasterProfile = null; public static final String PROP_CURRENTRASTERPROFILE = "currentRasterProfile"; /** * Get the value of currentRasterProfile * * @return the value of currentRasterProfile */ public Raster3dProfile getCurrentRasterProfile() { return currentRasterProfile; } /** * Set the value of currentRasterProfile * * @param currentRasterProfile new value of currentRasterProfile */ public void setCurrentRasterProfile(Raster3dProfile currentRasterProfile) { Raster3dProfile oldCurrentRasterProfile = this.currentRasterProfile; this.currentRasterProfile = currentRasterProfile; firePropertyChange(PROP_CURRENTRASTERPROFILE, oldCurrentRasterProfile, currentRasterProfile); } /** Creates new form EditRasterProfileDialog */ public EditRaster3dProfileDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); cbResolution.removeAllItems(); if (VisicutModel.getInstance().getSelectedLaserDevice() != null) { for (Double d: VisicutModel.getInstance().getSelectedLaserDevice().getLaserCutter().getResolutions()) { this.cbResolution.addItem(d); } } } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { bindingGroup = new org.jdesktop.beansbinding.BindingGroup(); jButton4 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); tfDescription = new javax.swing.JTextField(); lbDescription = new javax.swing.JLabel(); lbName = new javax.swing.JLabel(); tfName = new javax.swing.JTextField(); selectThumbnailButton1 = new com.t_oster.uicomponents.SelectThumbnailButton(); jCheckBox1 = new javax.swing.JCheckBox(); jSlider1 = new javax.swing.JSlider(); jLabel6 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); cbResolution = new javax.swing.JComboBox(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("com/t_oster/visicut/gui/resources/EditRaster3dProfileDialog"); // NOI18N setTitle(bundle.getString("TITLE")); // NOI18N setName("Form"); // NOI18N org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(com.t_oster.visicut.gui.VisicutApp.class).getContext().getResourceMap(EditRaster3dProfileDialog.class); jButton4.setText(resourceMap.getString("jButton4.text")); // NOI18N jButton4.setName("jButton4"); // NOI18N jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N jButton3.setName("jButton3"); // NOI18N jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); tfDescription.setName("tfDescription"); // NOI18N org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${currentRasterProfile.description}"), tfDescription, org.jdesktop.beansbinding.BeanProperty.create("text"), "desc"); bindingGroup.addBinding(binding); lbDescription.setText(resourceMap.getString("lbDescription.text")); // NOI18N lbDescription.setName("lbDescription"); // NOI18N lbName.setText(resourceMap.getString("lbName.text")); // NOI18N lbName.setName("lbName"); // NOI18N tfName.setName("tfName"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${currentRasterProfile.name}"), tfName, org.jdesktop.beansbinding.BeanProperty.create("text"), "Name"); bindingGroup.addBinding(binding); selectThumbnailButton1.setName("selectThumbnailButton1"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${currentRasterProfile.thumbnailPath}"), selectThumbnailButton1, org.jdesktop.beansbinding.BeanProperty.create("thumbnailPath"), "thumbnailbt"); bindingGroup.addBinding(binding); jCheckBox1.setText(resourceMap.getString("jCheckBox1.text")); // NOI18N jCheckBox1.setName("jCheckBox1"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${currentRasterProfile.invertColors}"), jCheckBox1, org.jdesktop.beansbinding.BeanProperty.create("selected"), "invcolors"); bindingGroup.addBinding(binding); jSlider1.setMaximum(255); jSlider1.setMinimum(-255); jSlider1.setToolTipText(resourceMap.getString("jSlider1.toolTipText")); // NOI18N jSlider1.setName("jSlider1"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${currentRasterProfile.colorShift}"), jSlider1, org.jdesktop.beansbinding.BeanProperty.create("value"), "colorshift"); bindingGroup.addBinding(binding); jLabel6.setText(resourceMap.getString("profile.greyscaleShift")); // NOI18N jLabel6.setName("jLabel6"); // NOI18N jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N jLabel1.setName("jLabel1"); // NOI18N cbResolution.setEditable(true); cbResolution.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cbResolution.setName("cbResolution"); // NOI18N binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${currentRasterProfile.DPI}"), cbResolution, org.jdesktop.beansbinding.BeanProperty.create("selectedItem"), "cbBinding"); bindingGroup.addBinding(binding); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jButton4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton3)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel6) .addComponent(jCheckBox1) .addComponent(lbDescription) .addComponent(selectThumbnailButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addGap(10, 10, 10) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(4, 4, 4) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(tfDescription, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE) .addComponent(lbName) .addComponent(tfName) .addComponent(cbResolution, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(lbName) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(tfName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(selectThumbnailButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lbDescription) .addComponent(tfDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(cbResolution, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(jCheckBox1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel6)) .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton3) .addComponent(jButton4)) .addContainerGap()) ); bindingGroup.bind(); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton4ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton4ActionPerformed {//GEN-HEADEREND:event_jButton4ActionPerformed this.setRasterProfile(null); this.setVisible(false); }//GEN-LAST:event_jButton4ActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton3ActionPerformed {//GEN-HEADEREND:event_jButton3ActionPerformed this.setRasterProfile(this.getCurrentRasterProfile()); this.setVisible(false); }//GEN-LAST:event_jButton3ActionPerformed /** * @param args the command line arguments */ // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox cbResolution; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JCheckBox jCheckBox1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel6; private javax.swing.JSlider jSlider1; private javax.swing.JLabel lbDescription; private javax.swing.JLabel lbName; private com.t_oster.uicomponents.SelectThumbnailButton selectThumbnailButton1; private javax.swing.JTextField tfDescription; private javax.swing.JTextField tfName; private org.jdesktop.beansbinding.BindingGroup bindingGroup; // End of variables declaration//GEN-END:variables void setNameEditable(boolean b) { tfName.setEnabled(b); } void setCancelable(boolean b) { this.jButton4.setVisible(false); } public void setOnlyEditParameters(boolean b) { this.tfName.setVisible(!b); this.lbName.setVisible(!b); this.lbDescription.setVisible(!b); this.tfDescription.setVisible(!b); this.selectThumbnailButton1.setVisible(!b); this.pack(); } }