|
@@ -16,20 +16,15 @@ import com.jme3.gde.core.properties.TexturePropertyEditor;
|
|
import com.jme3.gde.core.properties.preview.TexturePreview;
|
|
import com.jme3.gde.core.properties.preview.TexturePreview;
|
|
import com.jme3.gde.materials.MaterialProperty;
|
|
import com.jme3.gde.materials.MaterialProperty;
|
|
import com.jme3.gde.materials.multiview.MaterialEditorTopComponent;
|
|
import com.jme3.gde.materials.multiview.MaterialEditorTopComponent;
|
|
-import com.jme3.texture.Texture;
|
|
|
|
import java.awt.Component;
|
|
import java.awt.Component;
|
|
import java.awt.Graphics2D;
|
|
import java.awt.Graphics2D;
|
|
import java.awt.image.BufferedImage;
|
|
import java.awt.image.BufferedImage;
|
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
import java.util.logging.Logger;
|
|
-import javax.swing.Icon;
|
|
|
|
-import javax.swing.SwingUtilities;
|
|
|
|
-import jme3tools.converters.ImageToAwt;
|
|
|
|
-import org.openide.util.ImageUtilities;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
|
|
+ * The TexturePanel is a col in the material editor representing a special texture
|
|
* @author normenhansen
|
|
* @author normenhansen
|
|
*/
|
|
*/
|
|
public class TexturePanel extends MaterialPropertyWidget {
|
|
public class TexturePanel extends MaterialPropertyWidget {
|
|
@@ -38,7 +33,7 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|
private final ProjectAssetManager manager;
|
|
private final ProjectAssetManager manager;
|
|
private boolean flip = false;
|
|
private boolean flip = false;
|
|
private boolean repeat = false;
|
|
private boolean repeat = false;
|
|
- private String textureName = null;
|
|
|
|
|
|
+ protected String textureName = null; // always enclosed with ""
|
|
private TexturePreview texPreview;
|
|
private TexturePreview texPreview;
|
|
private final ScheduledThreadPoolExecutor exec = new ScheduledThreadPoolExecutor(1);
|
|
private final ScheduledThreadPoolExecutor exec = new ScheduledThreadPoolExecutor(1);
|
|
|
|
|
|
@@ -52,14 +47,13 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|
private void displayPreview() {
|
|
private void displayPreview() {
|
|
if (!"".equals(textureName)) {
|
|
if (!"".equals(textureName)) {
|
|
exec.execute(new Runnable() {
|
|
exec.execute(new Runnable() {
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
try{
|
|
try{
|
|
if (texPreview == null) {
|
|
if (texPreview == null) {
|
|
texPreview = new TexturePreview(manager);
|
|
texPreview = new TexturePreview(manager);
|
|
}
|
|
}
|
|
- texPreview.requestPreview(textureName, "", 80, 25, texturePreview, null);
|
|
|
|
|
|
+ texPreview.requestPreview(stripQuotes(textureName), "", 80, 25, texturePreview, null);
|
|
} catch (AssetNotFoundException a) {
|
|
} catch (AssetNotFoundException a) {
|
|
Logger.getLogger(MaterialEditorTopComponent.class.getName()).log(Level.WARNING, "Could not load texture {0}", textureName);
|
|
Logger.getLogger(MaterialEditorTopComponent.class.getName()).log(Level.WARNING, "Could not load texture {0}", textureName);
|
|
}
|
|
}
|
|
@@ -67,6 +61,10 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private String stripQuotes(String s) {
|
|
|
|
+ return s.substring(1, s.length() - 1);
|
|
|
|
+ }
|
|
|
|
|
|
private void updateFlipRepeat() {
|
|
private void updateFlipRepeat() {
|
|
if (flip && repeat) {
|
|
if (flip && repeat) {
|
|
@@ -243,12 +241,12 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|
Component view = editor.getCustomEditor();
|
|
Component view = editor.getCustomEditor();
|
|
view.setVisible(true);
|
|
view.setVisible(true);
|
|
if (editor.getValue() != null) {
|
|
if (editor.getValue() != null) {
|
|
- textureName = editor.getAsText();
|
|
|
|
|
|
+ textureName = "\"" + editor.getAsText() + "\"";
|
|
displayPreview();
|
|
displayPreview();
|
|
updateFlipRepeat();
|
|
updateFlipRepeat();
|
|
fireChanged();
|
|
fireChanged();
|
|
} else { // "No Texture" has been clicked
|
|
} else { // "No Texture" has been clicked
|
|
- textureName = "";
|
|
|
|
|
|
+ textureName = "\"\"";
|
|
texturePreview.setIcon(null);
|
|
texturePreview.setIcon(null);
|
|
texturePreview.setToolTipText("");
|
|
texturePreview.setToolTipText("");
|
|
property.setValue("");
|
|
property.setValue("");
|
|
@@ -257,7 +255,7 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|
}//GEN-LAST:event_jButton1ActionPerformed
|
|
}//GEN-LAST:event_jButton1ActionPerformed
|
|
|
|
|
|
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
|
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
|
- textureName = "";
|
|
|
|
|
|
+ textureName = "\"\"";
|
|
texturePreview.setIcon(null);
|
|
texturePreview.setIcon(null);
|
|
texturePreview.setToolTipText("");
|
|
texturePreview.setToolTipText("");
|
|
property.setValue("");
|
|
property.setValue("");
|
|
@@ -286,6 +284,7 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|
protected void readProperty() {
|
|
protected void readProperty() {
|
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
|
|
|
|
|
|
|
+ @Override
|
|
public void run() {
|
|
public void run() {
|
|
if (property.getValue().startsWith("Flip Repeat ")) {
|
|
if (property.getValue().startsWith("Flip Repeat ")) {
|
|
flip = true;
|
|
flip = true;
|