001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.vmd.game.editor.grid;
043:
044: import javax.swing.JScrollPane;
045: import org.netbeans.modules.vmd.game.model.Editable.ImageResourceInfo;
046: import org.netbeans.modules.vmd.game.model.ImageResource;
047: import org.openide.util.NbBundle;
048:
049: /**
050: *
051: * @author kherink
052: */
053: public class ResourceImageEditor extends javax.swing.JPanel {
054:
055: private ResourceImageList resourceComponent;
056:
057: /** Creates new form ResourceImageEditor */
058: public ResourceImageEditor() {
059: initComponents();
060:
061: this .getAccessibleContext().setAccessibleName(
062: NbBundle.getMessage(ResourceImageEditor.class,
063: "ResourceImageEditor.accessible.name"));
064: this .getAccessibleContext().setAccessibleDescription(
065: NbBundle.getMessage(ResourceImageEditor.class,
066: "ResourceImageEditor.accessible.description"));
067:
068: this .textFieldImage.setBackground(this .textFieldImage
069: .getParent().getBackground());
070: this .textFieldNumTiles.setBackground(this .textFieldNumTiles
071: .getParent().getBackground());
072: this .textFieldSize.setBackground(this .textFieldSize.getParent()
073: .getBackground());
074:
075: this .resourceComponent = new ResourceImageList();
076: this .panelResourceList.add(new JScrollPane(
077: this .resourceComponent));
078: }
079:
080: public void setImageResourceInfo(ImageResourceInfo imageResourceInfo) {
081: ImageResource imageResource = imageResourceInfo
082: .getImageResource();
083: int tileWidth = imageResourceInfo.getTileWidth();
084: int tileHeight = imageResourceInfo.getTileHeight();
085: boolean zeroBasedIndex = imageResourceInfo.isZeroBasedIndex();
086:
087: this .textFieldImage.setText(imageResource
088: .getRelativeResourcePath());
089: this .textFieldNumTiles.setText(Integer.toString(imageResource
090: .getStaticTileCount(tileWidth, tileHeight)));
091: this .textFieldSize.setText(org.openide.util.NbBundle
092: .getMessage(ResourceImageEditor.class,
093: "ResourceImageEditor.tileSize.txt", tileWidth,
094: tileHeight));
095: this .resourceComponent.setImageResource(imageResource,
096: tileWidth, tileHeight, zeroBasedIndex);
097: this .resourceComponent.setSelectedIndex(0);
098: }
099:
100: /** This method is called from within the constructor to
101: * initialize the form.
102: * WARNING: Do NOT modify this code. The content of this method is
103: * always regenerated by the Form Editor.
104: */
105: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
106: private void initComponents() {
107:
108: jPanel1 = new javax.swing.JPanel();
109: jLabel1 = new javax.swing.JLabel();
110: textFieldImage = new javax.swing.JTextField();
111: jLabel2 = new javax.swing.JLabel();
112: textFieldNumTiles = new javax.swing.JTextField();
113: jLabel3 = new javax.swing.JLabel();
114: textFieldSize = new javax.swing.JTextField();
115: panelResourceList = new javax.swing.JPanel();
116:
117: jLabel1.setLabelFor(textFieldImage);
118: jLabel1.setText(org.openide.util.NbBundle.getMessage(
119: ResourceImageEditor.class,
120: "ResourceImageEditor.labelImage.txt")); // NOI18N
121:
122: textFieldImage.setEditable(false);
123: textFieldImage.setBorder(null);
124:
125: jLabel2.setLabelFor(textFieldNumTiles);
126: jLabel2.setText(org.openide.util.NbBundle.getMessage(
127: ResourceImageEditor.class,
128: "ResourceImageEditor.labelCount.txt")); // NOI18N
129:
130: textFieldNumTiles.setEditable(false);
131: textFieldNumTiles.setBorder(null);
132:
133: jLabel3.setLabelFor(textFieldSize);
134: jLabel3.setText(org.openide.util.NbBundle.getMessage(
135: ResourceImageEditor.class,
136: "ResourceImageEditor.tileSizeLbl.txt")); // NOI18N
137:
138: textFieldSize.setEditable(false);
139: textFieldSize.setBorder(null);
140:
141: org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(
142: jPanel1);
143: jPanel1.setLayout(jPanel1Layout);
144: jPanel1Layout
145: .setHorizontalGroup(jPanel1Layout
146: .createParallelGroup(
147: org.jdesktop.layout.GroupLayout.LEADING)
148: .add(
149: jPanel1Layout
150: .createSequentialGroup()
151: .addContainerGap()
152: .add(jLabel1)
153: .addPreferredGap(
154: org.jdesktop.layout.LayoutStyle.RELATED)
155: .add(
156: textFieldImage,
157: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
158: 254, Short.MAX_VALUE)
159: .add(24, 24, 24)
160: .add(jLabel2)
161: .addPreferredGap(
162: org.jdesktop.layout.LayoutStyle.RELATED)
163: .add(
164: textFieldNumTiles,
165: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
166: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
167: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
168: .addPreferredGap(
169: org.jdesktop.layout.LayoutStyle.RELATED)
170: .add(jLabel3)
171: .addPreferredGap(
172: org.jdesktop.layout.LayoutStyle.RELATED)
173: .add(
174: textFieldSize,
175: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
176: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
177: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
178: .addContainerGap()));
179: jPanel1Layout
180: .setVerticalGroup(jPanel1Layout
181: .createParallelGroup(
182: org.jdesktop.layout.GroupLayout.LEADING)
183: .add(
184: org.jdesktop.layout.GroupLayout.TRAILING,
185: textFieldSize,
186: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
187: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
188: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
189: .add(
190: org.jdesktop.layout.GroupLayout.TRAILING,
191: textFieldImage,
192: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
193: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
194: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
195: .add(
196: org.jdesktop.layout.GroupLayout.TRAILING,
197: textFieldNumTiles,
198: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
199: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
200: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
201: .add(org.jdesktop.layout.GroupLayout.TRAILING,
202: jLabel3)
203: .add(org.jdesktop.layout.GroupLayout.TRAILING,
204: jLabel2)
205: .add(org.jdesktop.layout.GroupLayout.TRAILING,
206: jLabel1));
207:
208: panelResourceList.setBackground(new java.awt.Color(255, 255,
209: 255));
210: panelResourceList.setLayout(new java.awt.BorderLayout());
211:
212: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
213: this );
214: this .setLayout(layout);
215: layout.setHorizontalGroup(layout.createParallelGroup(
216: org.jdesktop.layout.GroupLayout.LEADING).add(jPanel1,
217: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
218: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
219: Short.MAX_VALUE).add(panelResourceList,
220: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 487,
221: Short.MAX_VALUE));
222: layout
223: .setVerticalGroup(layout
224: .createParallelGroup(
225: org.jdesktop.layout.GroupLayout.LEADING)
226: .add(
227: layout
228: .createSequentialGroup()
229: .add(
230: jPanel1,
231: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
232: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
233: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
234: .addPreferredGap(
235: org.jdesktop.layout.LayoutStyle.RELATED)
236: .add(
237: panelResourceList,
238: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
239: 142, Short.MAX_VALUE)));
240: }// </editor-fold>//GEN-END:initComponents
241:
242: // Variables declaration - do not modify//GEN-BEGIN:variables
243: private javax.swing.JLabel jLabel1;
244: private javax.swing.JLabel jLabel2;
245: private javax.swing.JLabel jLabel3;
246: private javax.swing.JPanel jPanel1;
247: private javax.swing.JPanel panelResourceList;
248: private javax.swing.JTextField textFieldImage;
249: private javax.swing.JTextField textFieldNumTiles;
250: private javax.swing.JTextField textFieldSize;
251: // End of variables declaration//GEN-END:variables
252:
253: }
|