Merge branch 'kruland-integration' of ssh://github.com/plaa/openrocket into kruland-integration
This commit is contained in:
commit
1c04713131
@ -725,6 +725,7 @@ AppearanceCfg.lbl.Usedefault = Use default
|
|||||||
AppearanceCfg.but.savedefault = Save as default appearance
|
AppearanceCfg.but.savedefault = Save as default appearance
|
||||||
AppearanceCfg.lbl.Texture = Texture:
|
AppearanceCfg.lbl.Texture = Texture:
|
||||||
AppearanceCfg.lbl.shine = Shine:
|
AppearanceCfg.lbl.shine = Shine:
|
||||||
|
AppearanceCfg.lbl.color.Color = Color:
|
||||||
AppearanceCfg.lbl.color.diffuse = Diffuse Color:
|
AppearanceCfg.lbl.color.diffuse = Diffuse Color:
|
||||||
AppearanceCfg.lbl.color.ambient = Ambient Color:
|
AppearanceCfg.lbl.color.ambient = Ambient Color:
|
||||||
AppearanceCfg.lbl.color.specular = Specular Color:
|
AppearanceCfg.lbl.color.specular = Specular Color:
|
||||||
@ -1061,10 +1062,6 @@ StorageOptChooser.lbl.seconds = seconds
|
|||||||
StorageOptChooser.rdbut.Onlyprimfig = Only primary figures
|
StorageOptChooser.rdbut.Onlyprimfig = Only primary figures
|
||||||
StorageOptChooser.lbl.longC1 = <html>Store only the values shown in the summary table.<br>
|
StorageOptChooser.lbl.longC1 = <html>Store only the values shown in the summary table.<br>
|
||||||
StorageOptChooser.lbl.longC2 = This results in the smallest files.
|
StorageOptChooser.lbl.longC2 = This results in the smallest files.
|
||||||
StorageOptChooser.checkbox.IncludeDecals = Include decals
|
|
||||||
StorageOptChooser.lbl.IncludeDecals = "Including decals will produce a compressed zip file"
|
|
||||||
StorageOptChooser.checkbox.Compfile = Compress file
|
|
||||||
StorageOptChooser.lbl.UsingComp = Using compression reduces the file size significantly.
|
|
||||||
StorageOptChooser.lbl.longD1 = An estimate on how large the resulting file would be with the present options.
|
StorageOptChooser.lbl.longD1 = An estimate on how large the resulting file would be with the present options.
|
||||||
StorageOptChooser.ttip.Saveopt = Save options
|
StorageOptChooser.ttip.Saveopt = Save options
|
||||||
StorageOptChooser.lbl.Estfilesize = Estimated file size:
|
StorageOptChooser.lbl.Estfilesize = Estimated file size:
|
||||||
|
|||||||
@ -27,10 +27,6 @@ public class DecalRegistry {
|
|||||||
private boolean isZipFile = false;
|
private boolean isZipFile = false;
|
||||||
|
|
||||||
private Map<String,File> exportedDecalMap = new HashMap<String,File>();
|
private Map<String,File> exportedDecalMap = new HashMap<String,File>();
|
||||||
|
|
||||||
/* TODO - should we implement caching?
|
|
||||||
private Map<String,byte[]> cache = new HashMap<String,byte[]>();
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void setBaseFile(FileInfo fileInfo) {
|
public void setBaseFile(FileInfo fileInfo) {
|
||||||
this.fileInfo = fileInfo;
|
this.fileInfo = fileInfo;
|
||||||
@ -52,7 +48,7 @@ public class DecalRegistry {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
InputStream is = forwardToEntry(name);
|
InputStream is = findInZipContainer(name);
|
||||||
if ( is != null ) {
|
if ( is != null ) {
|
||||||
is.close();
|
is.close();
|
||||||
return true;
|
return true;
|
||||||
@ -63,7 +59,7 @@ public class DecalRegistry {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns an InputStream backed by a byte[] containing the decal pixels.
|
* This function returns an InputStream backed by a byte[] containing the decal pixels.
|
||||||
* If it reads in the bytes from an actual file, the underlying file is closed.
|
* If it reads in the bytes from an actual file, the underlying file is closed.
|
||||||
@ -74,18 +70,11 @@ public class DecalRegistry {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public InputStream getDecal( String name ) throws FileNotFoundException, IOException {
|
public InputStream getDecal( String name ) throws FileNotFoundException, IOException {
|
||||||
/* TODO
|
|
||||||
// if the decal has already been cached return it.
|
|
||||||
byte[] bytes = cache.get(name);
|
|
||||||
if ( bytes != null ) {
|
|
||||||
return new ByteArrayInputStream(bytes);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// This is the InputStream to be returned.
|
// This is the InputStream to be returned.
|
||||||
InputStream rawIs = null;
|
InputStream rawIs = null;
|
||||||
|
|
||||||
|
|
||||||
// First check if the decal had been exported
|
// First check if the decal had been exported
|
||||||
{
|
{
|
||||||
File exportedFile= exportedDecalMap.get(name);
|
File exportedFile= exportedDecalMap.get(name);
|
||||||
@ -101,7 +90,7 @@ public class DecalRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( rawIs == null && isZipFile ) {
|
if ( rawIs == null && isZipFile ) {
|
||||||
rawIs = forwardToEntry(name);
|
rawIs = findInZipContainer(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check absolute file name:
|
// Check absolute file name:
|
||||||
@ -131,7 +120,6 @@ public class DecalRegistry {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
byte[] bytes = FileUtils.readBytes(rawIs);
|
byte[] bytes = FileUtils.readBytes(rawIs);
|
||||||
// TODO - here we would update the cache.
|
|
||||||
return new ByteArrayInputStream(bytes);
|
return new ByteArrayInputStream(bytes);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
@ -141,7 +129,7 @@ public class DecalRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void exportDecal( String decalName, File selectedFile ) throws IOException {
|
public void exportDecal( String decalName, File selectedFile ) throws IOException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InputStream is = getDecal(decalName);
|
InputStream is = getDecal(decalName);
|
||||||
OutputStream os = new BufferedOutputStream( new FileOutputStream(selectedFile));
|
OutputStream os = new BufferedOutputStream( new FileOutputStream(selectedFile));
|
||||||
@ -150,21 +138,26 @@ public class DecalRegistry {
|
|||||||
|
|
||||||
is.close();
|
is.close();
|
||||||
os.close();
|
os.close();
|
||||||
|
|
||||||
exportedDecalMap.put(decalName, selectedFile );
|
exportedDecalMap.put(decalName, selectedFile );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException iex) {
|
catch (IOException iex) {
|
||||||
throw new BugException(iex);
|
throw new BugException(iex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ZipInputStream forwardToEntry( String name ) throws IOException {
|
private ZipInputStream findInZipContainer( String name ) {
|
||||||
ZipInputStream zis = new ZipInputStream(fileInfo.fileURL.openStream());
|
ZipInputStream zis = null;
|
||||||
|
try {
|
||||||
|
zis = new ZipInputStream(fileInfo.fileURL.openStream());
|
||||||
|
} catch( IOException ex ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
ZipEntry entry = zis.getNextEntry();
|
ZipEntry entry = zis.getNextEntry();
|
||||||
while ( entry != null ) {
|
while ( entry != null ) {
|
||||||
@ -173,12 +166,16 @@ public class DecalRegistry {
|
|||||||
}
|
}
|
||||||
entry = zis.getNextEntry();
|
entry = zis.getNextEntry();
|
||||||
}
|
}
|
||||||
|
zis.close();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
catch ( IOException ioex ) {
|
catch ( IOException ioex ) {
|
||||||
zis.close();
|
try {
|
||||||
throw ioex;
|
zis.close();
|
||||||
|
} catch ( IOException ex ) {
|
||||||
|
// why does close throw? it's maddening
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
zis.close();
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,10 +14,6 @@ public class StorageOptions implements Cloneable {
|
|||||||
|
|
||||||
private FileType fileType = FileType.OPENROCKET;
|
private FileType fileType = FileType.OPENROCKET;
|
||||||
|
|
||||||
private boolean includeDecals = false;
|
|
||||||
|
|
||||||
private boolean compressionEnabled = true;
|
|
||||||
|
|
||||||
private double simulationTimeSkip = SIMULATION_DATA_NONE;
|
private double simulationTimeSkip = SIMULATION_DATA_NONE;
|
||||||
|
|
||||||
private boolean explicitlySet = false;
|
private boolean explicitlySet = false;
|
||||||
@ -30,22 +26,6 @@ public class StorageOptions implements Cloneable {
|
|||||||
this.fileType = fileType;
|
this.fileType = fileType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncludeDecals() {
|
|
||||||
return includeDecals;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIncludeDecals(boolean includeDecals) {
|
|
||||||
this.includeDecals = includeDecals;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCompressionEnabled() {
|
|
||||||
return compressionEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCompressionEnabled(boolean compression) {
|
|
||||||
this.compressionEnabled = compression;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getSimulationTimeSkip() {
|
public double getSimulationTimeSkip() {
|
||||||
return simulationTimeSkip;
|
return simulationTimeSkip;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,7 +106,6 @@ public class GeneralRocketLoader {
|
|||||||
// Check for GZIP
|
// Check for GZIP
|
||||||
if (buffer[0] == GZIP_SIGNATURE[0] && buffer[1] == GZIP_SIGNATURE[1]) {
|
if (buffer[0] == GZIP_SIGNATURE[0] && buffer[1] == GZIP_SIGNATURE[1]) {
|
||||||
OpenRocketDocument doc = loadFromStream(new GZIPInputStream(source), motorFinder);
|
OpenRocketDocument doc = loadFromStream(new GZIPInputStream(source), motorFinder);
|
||||||
doc.getDefaultStorageOptions().setCompressionEnabled(true);
|
|
||||||
doc.getDecalRegistry().setIsZipFile(false);
|
doc.getDecalRegistry().setIsZipFile(false);
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
@ -122,8 +121,6 @@ public class GeneralRocketLoader {
|
|||||||
}
|
}
|
||||||
if (entry.getName().matches(".*\\.[oO][rR][kK]$")) {
|
if (entry.getName().matches(".*\\.[oO][rR][kK]$")) {
|
||||||
OpenRocketDocument doc = loadFromStream(in, motorFinder);
|
OpenRocketDocument doc = loadFromStream(in, motorFinder);
|
||||||
doc.getDefaultStorageOptions().setCompressionEnabled(true);
|
|
||||||
doc.getDefaultStorageOptions().setIncludeDecals(true);
|
|
||||||
doc.getDecalRegistry().setIsZipFile(true);
|
doc.getDecalRegistry().setIsZipFile(true);
|
||||||
return doc;
|
return doc;
|
||||||
} else if ( entry.getName().matches(".*\\.[rR][kK][tT]$")) {
|
} else if ( entry.getName().matches(".*\\.[rR][kK][tT]$")) {
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import net.sf.openrocket.appearance.AppearanceBuilder;
|
|||||||
import net.sf.openrocket.appearance.Decal;
|
import net.sf.openrocket.appearance.Decal;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.document.StorageOptions;
|
import net.sf.openrocket.document.StorageOptions;
|
||||||
|
import net.sf.openrocket.document.StorageOptions.FileType;
|
||||||
import net.sf.openrocket.file.openrocket.OpenRocketSaver;
|
import net.sf.openrocket.file.openrocket.OpenRocketSaver;
|
||||||
import net.sf.openrocket.file.rocksim.export.RocksimSaver;
|
import net.sf.openrocket.file.rocksim.export.RocksimSaver;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
@ -146,24 +147,15 @@ public class GeneralRocketSaver {
|
|||||||
|
|
||||||
private void save(String fileName, OutputStream output, OpenRocketDocument document, StorageOptions options) throws IOException {
|
private void save(String fileName, OutputStream output, OpenRocketDocument document, StorageOptions options) throws IOException {
|
||||||
|
|
||||||
// If we don't include decals, just write the simple file.
|
// For now, we don't save decal inforamtion in ROCKSIM files, so don't do anything
|
||||||
if (!options.isIncludeDecals()) {
|
// which follows.
|
||||||
saveInternal(output,document,options);
|
// TODO - add support for decals in ROCKSIM files?
|
||||||
|
if ( options.getFileType() == FileType.ROCKSIM ) {
|
||||||
|
saveInternal(output, document, options);
|
||||||
|
output.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We're saving decals, so the result will be a zip file. There's no
|
|
||||||
// need to gzip the rocket model file in the archive.
|
|
||||||
options.setCompressionEnabled(false);
|
|
||||||
|
|
||||||
/* if we want a directory ...
|
|
||||||
String path = fileName;
|
|
||||||
int dotlocation = fileName.lastIndexOf('.');
|
|
||||||
if ( dotlocation > 1 ) {
|
|
||||||
path = fileName.substring(dotlocation);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// grab the set of decal images. We do this up front
|
// grab the set of decal images. We do this up front
|
||||||
// so we can fail early if some resource is missing.
|
// so we can fail early if some resource is missing.
|
||||||
|
|
||||||
@ -239,7 +231,12 @@ public class GeneralRocketSaver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now we have to loop through all the components and update their names.
|
// Now we have to loop through all the components and update their names.
|
||||||
for( RocketComponent c : document.getRocket() ) {
|
|
||||||
|
// First we copy the OpenRocketDocument so we can modify the decal file names
|
||||||
|
// without changing the ui's copy. This is so the ui will continue to
|
||||||
|
// use the exported decals.
|
||||||
|
OpenRocketDocument rocketDocCopy = document.copy();
|
||||||
|
for( RocketComponent c : rocketDocCopy.getRocket() ) {
|
||||||
|
|
||||||
if ( c.getAppearance() == null ) {
|
if ( c.getAppearance() == null ) {
|
||||||
continue;
|
continue;
|
||||||
@ -258,7 +255,19 @@ public class GeneralRocketSaver {
|
|||||||
c.setAppearance(builder.getAppearance());
|
c.setAppearance(builder.getAppearance());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String,InputStream> decalMap = new HashMap<String,InputStream>();
|
||||||
|
for( Map.Entry<String, InputStream> image : decals.entrySet() ) {
|
||||||
|
|
||||||
|
String newName = decalNameNormalization.get(image.getKey());
|
||||||
|
decalMap.put(newName, image.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
saveAllPartsZipFile(fileName, output, rocketDocCopy, options, decalMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveAllPartsZipFile(String fileName, OutputStream output, OpenRocketDocument document, StorageOptions options, Map<String,InputStream> decals) throws IOException {
|
||||||
|
|
||||||
// Open a zip stream to write to.
|
// Open a zip stream to write to.
|
||||||
ZipOutputStream zos = new ZipOutputStream(output);
|
ZipOutputStream zos = new ZipOutputStream(output);
|
||||||
zos.setLevel(9);
|
zos.setLevel(9);
|
||||||
@ -275,8 +284,8 @@ public class GeneralRocketSaver {
|
|||||||
|
|
||||||
for( Map.Entry<String, InputStream> image : decals.entrySet() ) {
|
for( Map.Entry<String, InputStream> image : decals.entrySet() ) {
|
||||||
|
|
||||||
String newName = decalNameNormalization.get(image.getKey());
|
String name = image.getKey();
|
||||||
ZipEntry decal = new ZipEntry(newName);
|
ZipEntry decal = new ZipEntry(name);
|
||||||
zos.putNextEntry(decal);
|
zos.putNextEntry(decal);
|
||||||
|
|
||||||
InputStream is = image.getValue();
|
InputStream is = image.getValue();
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.zip.GZIPOutputStream;
|
|
||||||
|
|
||||||
import net.sf.openrocket.aerodynamics.Warning;
|
import net.sf.openrocket.aerodynamics.Warning;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
@ -57,11 +56,8 @@ public class OpenRocketSaver extends RocketSaver {
|
|||||||
|
|
||||||
// Estimated storage used by different portions
|
// Estimated storage used by different portions
|
||||||
// These have been hand-estimated from saved files
|
// These have been hand-estimated from saved files
|
||||||
private static final int BYTES_PER_COMPONENT_UNCOMPRESSED = 590;
|
|
||||||
private static final int BYTES_PER_COMPONENT_COMPRESSED = 80;
|
private static final int BYTES_PER_COMPONENT_COMPRESSED = 80;
|
||||||
private static final int BYTES_PER_SIMULATION_UNCOMPRESSED = 1000;
|
|
||||||
private static final int BYTES_PER_SIMULATION_COMPRESSED = 100;
|
private static final int BYTES_PER_SIMULATION_COMPRESSED = 100;
|
||||||
private static final int BYTES_PER_DATAPOINT_UNCOMPRESSED = 350;
|
|
||||||
private static final int BYTES_PER_DATAPOINT_COMPRESSED = 100;
|
private static final int BYTES_PER_DATAPOINT_COMPRESSED = 100;
|
||||||
|
|
||||||
|
|
||||||
@ -73,11 +69,6 @@ public class OpenRocketSaver extends RocketSaver {
|
|||||||
|
|
||||||
log.info("Saving .ork file");
|
log.info("Saving .ork file");
|
||||||
|
|
||||||
if (options.isCompressionEnabled()) {
|
|
||||||
log.debug("Enabling compression");
|
|
||||||
output = new GZIPOutputStream(output);
|
|
||||||
}
|
|
||||||
|
|
||||||
dest = new BufferedWriter(new OutputStreamWriter(output, OPENROCKET_CHARSET));
|
dest = new BufferedWriter(new OutputStreamWriter(output, OPENROCKET_CHARSET));
|
||||||
|
|
||||||
// Select file version number
|
// Select file version number
|
||||||
@ -121,9 +112,6 @@ public class OpenRocketSaver extends RocketSaver {
|
|||||||
|
|
||||||
log.debug("Writing complete, flushing buffers");
|
log.debug("Writing complete, flushing buffers");
|
||||||
dest.flush();
|
dest.flush();
|
||||||
if (options.isCompressionEnabled()) {
|
|
||||||
((GZIPOutputStream) output).finish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -178,17 +166,11 @@ public class OpenRocketSaver extends RocketSaver {
|
|||||||
componentCount++;
|
componentCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.isCompressionEnabled())
|
size += componentCount * BYTES_PER_COMPONENT_COMPRESSED;
|
||||||
size += componentCount * BYTES_PER_COMPONENT_COMPRESSED;
|
|
||||||
else
|
|
||||||
size += componentCount * BYTES_PER_COMPONENT_UNCOMPRESSED;
|
|
||||||
|
|
||||||
|
|
||||||
// Size per simulation
|
// Size per simulation
|
||||||
if (options.isCompressionEnabled())
|
size += doc.getSimulationCount() * BYTES_PER_SIMULATION_COMPRESSED;
|
||||||
size += doc.getSimulationCount() * BYTES_PER_SIMULATION_COMPRESSED;
|
|
||||||
else
|
|
||||||
size += doc.getSimulationCount() * BYTES_PER_SIMULATION_UNCOMPRESSED;
|
|
||||||
|
|
||||||
|
|
||||||
// Size per flight data point
|
// Size per flight data point
|
||||||
@ -205,10 +187,7 @@ public class OpenRocketSaver extends RocketSaver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.isCompressionEnabled())
|
size += pointCount * BYTES_PER_DATAPOINT_COMPRESSED;
|
||||||
size += pointCount * BYTES_PER_DATAPOINT_COMPRESSED;
|
|
||||||
else
|
|
||||||
size += pointCount * BYTES_PER_DATAPOINT_UNCOMPRESSED;
|
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,7 +84,6 @@ public class OpenRocketLoader extends AbstractRocketLoader {
|
|||||||
timeSkip = Math.rint(timeSkip * 100) / 100;
|
timeSkip = Math.rint(timeSkip * 100) / 100;
|
||||||
|
|
||||||
doc.getDefaultStorageOptions().setSimulationTimeSkip(timeSkip);
|
doc.getDefaultStorageOptions().setSimulationTimeSkip(timeSkip);
|
||||||
doc.getDefaultStorageOptions().setCompressionEnabled(false); // Set by caller if compressed
|
|
||||||
doc.getDefaultStorageOptions().setExplicitlySet(false);
|
doc.getDefaultStorageOptions().setExplicitlySet(false);
|
||||||
|
|
||||||
doc.clearUndo();
|
doc.clearUndo();
|
||||||
|
|||||||
@ -62,7 +62,6 @@ public class RocksimSaver extends RocketSaver {
|
|||||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(dest, "UTF-8"));
|
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(dest, "UTF-8"));
|
||||||
writer.write(marshalToRocksim(doc));
|
writer.write(marshalToRocksim(doc));
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -39,9 +39,6 @@ public class StorageOptionChooser extends JPanel {
|
|||||||
|
|
||||||
private JSpinner timeSpinner;
|
private JSpinner timeSpinner;
|
||||||
|
|
||||||
private JCheckBox compressButton;
|
|
||||||
private JCheckBox decalButton;
|
|
||||||
|
|
||||||
private JLabel estimateLabel;
|
private JLabel estimateLabel;
|
||||||
|
|
||||||
|
|
||||||
@ -123,22 +120,6 @@ public class StorageOptionChooser extends JPanel {
|
|||||||
noneButton.addActionListener(actionUpdater);
|
noneButton.addActionListener(actionUpdater);
|
||||||
this.add(noneButton, "spanx, wrap 20lp");
|
this.add(noneButton, "spanx, wrap 20lp");
|
||||||
|
|
||||||
//// Save decals
|
|
||||||
// FIXME - should we hide this if there are no decals?
|
|
||||||
decalButton = new JCheckBox(trans.get("StorageOptChooser.checkbox.IncludeDecals"));
|
|
||||||
decalButton.setToolTipText(trans.get("StorageOptChooser.lbl.IncludeDecals"));
|
|
||||||
decalButton.addActionListener(actionUpdater);
|
|
||||||
this.add(decalButton, "spanx, wrap para");
|
|
||||||
|
|
||||||
//// Compress file
|
|
||||||
// FIXME - if the user selects save decals, should we automatically select compress file?
|
|
||||||
compressButton = new JCheckBox(trans.get("StorageOptChooser.checkbox.Compfile"));
|
|
||||||
//// Using compression reduces the file size significantly.
|
|
||||||
compressButton.setToolTipText(trans.get("StorageOptChooser.lbl.UsingComp"));
|
|
||||||
compressButton.addActionListener(actionUpdater);
|
|
||||||
this.add(compressButton, "spanx, wrap para");
|
|
||||||
|
|
||||||
|
|
||||||
// Estimate is updated in loadOptions(opts)
|
// Estimate is updated in loadOptions(opts)
|
||||||
estimateLabel = new JLabel("");
|
estimateLabel = new JLabel("");
|
||||||
//// An estimate on how large the resulting file would
|
//// An estimate on how large the resulting file would
|
||||||
@ -176,10 +157,6 @@ public class StorageOptionChooser extends JPanel {
|
|||||||
timeSpinner.setValue(t);
|
timeSpinner.setValue(t);
|
||||||
artificialEvent = false;
|
artificialEvent = false;
|
||||||
|
|
||||||
// Compression checkbox
|
|
||||||
compressButton.setSelected(opts.isCompressionEnabled());
|
|
||||||
decalButton.setSelected(opts.isIncludeDecals());
|
|
||||||
|
|
||||||
updateEstimate();
|
updateEstimate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,9 +174,6 @@ public class StorageOptionChooser extends JPanel {
|
|||||||
|
|
||||||
opts.setSimulationTimeSkip(t);
|
opts.setSimulationTimeSkip(t);
|
||||||
|
|
||||||
opts.setIncludeDecals(decalButton.isSelected());
|
|
||||||
opts.setCompressionEnabled(compressButton.isSelected());
|
|
||||||
|
|
||||||
opts.setExplicitlySet(true);
|
opts.setExplicitlySet(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,11 @@ public class AppearancePanel extends JPanel {
|
|||||||
|
|
||||||
private SimpleAppearanceBuilder ab;
|
private SimpleAppearanceBuilder ab;
|
||||||
|
|
||||||
private final static UnitGroup UNIT_FOR_SCALES = new UnitGroup();
|
/**
|
||||||
|
* A non-unit that adjusts by a small amount, suitable for
|
||||||
|
* values that are on the 0-1 scale
|
||||||
|
*/
|
||||||
|
private final static UnitGroup TEXTURE_UNIT = new UnitGroup();
|
||||||
static {
|
static {
|
||||||
Unit no_unit = new GeneralUnit(1,"",2) {
|
Unit no_unit = new GeneralUnit(1,"",2) {
|
||||||
@Override
|
@Override
|
||||||
@ -63,7 +67,7 @@ public class AppearancePanel extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
UNIT_FOR_SCALES.addUnit(no_unit);
|
TEXTURE_UNIT.addUnit(no_unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final JColorChooser colorChooser = new JColorChooser();
|
private static final JColorChooser colorChooser = new JColorChooser();
|
||||||
@ -117,11 +121,7 @@ public class AppearancePanel extends JPanel {
|
|||||||
}
|
}
|
||||||
final JButton figureColorButton = new JButton(new ColorIcon(figureColor));
|
final JButton figureColorButton = new JButton(new ColorIcon(figureColor));
|
||||||
|
|
||||||
/*final JButton diffuseColorButton = new JButton(new ColorIcon(ab.getDiffuse()));
|
final JButton colorButton = new JButton(new ColorIcon(ab.getColor()));
|
||||||
final JButton ambientColorButton = new JButton(new ColorIcon(ab.getAmbient()));
|
|
||||||
final JButton specularColorButton = new JButton(new ColorIcon(ab.getSpecular()));*/
|
|
||||||
|
|
||||||
final JButton colorButton = new JButton(new ColorIcon(ab.getAmbient()));
|
|
||||||
|
|
||||||
final JComboBox textureDropDown = new JComboBox( new DecalModel(this,document,ab));;
|
final JComboBox textureDropDown = new JComboBox( new DecalModel(this,document,ab));;
|
||||||
|
|
||||||
@ -129,9 +129,6 @@ public class AppearancePanel extends JPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void stateChanged(EventObject e) {
|
public void stateChanged(EventObject e) {
|
||||||
figureColorButton.setIcon(new ColorIcon(c.getColor()));
|
figureColorButton.setIcon(new ColorIcon(c.getColor()));
|
||||||
/*diffuseColorButton.setIcon(new ColorIcon(ab.getDiffuse()));
|
|
||||||
ambientColorButton.setIcon(new ColorIcon(ab.getAmbient()));
|
|
||||||
specularColorButton.setIcon(new ColorIcon(ab.getSpecular()));*/
|
|
||||||
colorButton.setIcon(new ColorIcon(ab.getColor()));
|
colorButton.setIcon(new ColorIcon(ab.getColor()));
|
||||||
c.setAppearance(ab.getAppearance());
|
c.setAppearance(ab.getAppearance());
|
||||||
}
|
}
|
||||||
@ -150,11 +147,7 @@ public class AppearancePanel extends JPanel {
|
|||||||
|
|
||||||
figureColorButton.addActionListener(new ColorActionListener(c, "Color"));
|
figureColorButton.addActionListener(new ColorActionListener(c, "Color"));
|
||||||
colorButton.addActionListener(new ColorActionListener(ab, "Color"));
|
colorButton.addActionListener(new ColorActionListener(ab, "Color"));
|
||||||
/*diffuseColorButton.addActionListener(new ColorActionListener(ab, "Diffuse"));
|
|
||||||
ambientColorButton.addActionListener(new ColorActionListener(ab, "Ambient"));
|
|
||||||
specularColorButton.addActionListener(new ColorActionListener(ab, "Specular"));*/
|
|
||||||
|
|
||||||
BooleanModel mDefault = new BooleanModel(c.getAppearance() == null);
|
|
||||||
BooleanModel fDefault = new BooleanModel(c.getColor() == null);
|
BooleanModel fDefault = new BooleanModel(c.getColor() == null);
|
||||||
|
|
||||||
|
|
||||||
@ -220,66 +213,50 @@ public class AppearancePanel extends JPanel {
|
|||||||
|
|
||||||
{// Texture Header Row
|
{// Texture Header Row
|
||||||
add(new StyledLabel(trans.get("AppearanceCfg.lbl.Appearance"), Style.BOLD), "wrap");
|
add(new StyledLabel(trans.get("AppearanceCfg.lbl.Appearance"), Style.BOLD), "wrap");
|
||||||
|
|
||||||
final JCheckBox materialDefault = new JCheckBox(mDefault);
|
|
||||||
materialDefault.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (materialDefault.isSelected()) {
|
|
||||||
c.setAppearance(null);
|
|
||||||
} else {
|
|
||||||
c.setAppearance(ab.getAppearance());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{// Texture File
|
{// Texture File
|
||||||
add(new JLabel(trans.get("AppearanceCfg.lbl.Texture")));
|
add(new JLabel(trans.get("AppearanceCfg.lbl.Texture")));
|
||||||
JPanel p = new JPanel(new MigLayout("fill, ins 0", "[grow][]"));
|
JPanel p = new JPanel(new MigLayout("fill, ins 0", "[grow][]"));
|
||||||
mDefault.addEnableComponent(textureDropDown, false);
|
|
||||||
p.add(textureDropDown, "grow");
|
p.add(textureDropDown, "grow");
|
||||||
add(p, "span 3, growx, wrap");
|
add(p, "span 3, growx, wrap");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*{ // Diffuse
|
|
||||||
add(new JLabel(trans.get("AppearanceCfg.lbl.color.diffuse")));
|
|
||||||
mDefault.addEnableComponent(diffuseColorButton, false);
|
|
||||||
add(diffuseColorButton);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
{ // Color
|
{ // Color
|
||||||
add(new JLabel("Color"));
|
add(new JLabel(trans.get("AppearanceCfg.lbl.color.Color")));
|
||||||
mDefault.addEnableComponent(colorButton, false);
|
//mDefault.addEnableComponent(colorButton, false);
|
||||||
|
colorButton.setEnabled(ab.getImage() == null);
|
||||||
add(colorButton);
|
add(colorButton);
|
||||||
|
ab.addChangeListener(new StateChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void stateChanged(EventObject e) {
|
||||||
|
colorButton.setEnabled(ab.getImage() == null);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Scale
|
{ // Scale
|
||||||
add(new JLabel(trans.get("AppearanceCfg.lbl.texture.scale")));
|
add(new JLabel(trans.get("AppearanceCfg.lbl.texture.scale")));
|
||||||
|
|
||||||
add(new JLabel("x:"), "split 4");
|
add(new JLabel("x:"), "split 4");
|
||||||
JSpinner scaleU = new JSpinner(new DoubleModel(ab, "ScaleX",UNIT_FOR_SCALES).getSpinnerModel());
|
JSpinner scaleU = new JSpinner(new DoubleModel(ab, "ScaleX", TEXTURE_UNIT).getSpinnerModel());
|
||||||
scaleU.setEditor(new SpinnerEditor(scaleU));
|
scaleU.setEditor(new SpinnerEditor(scaleU));
|
||||||
mDefault.addEnableComponent(scaleU, false);
|
|
||||||
add(scaleU, "w 40");
|
add(scaleU, "w 40");
|
||||||
|
|
||||||
add(new JLabel("y:"));
|
add(new JLabel("y:"));
|
||||||
JSpinner scaleV = new JSpinner(new DoubleModel(ab, "ScaleY",UNIT_FOR_SCALES).getSpinnerModel());
|
JSpinner scaleV = new JSpinner(new DoubleModel(ab, "ScaleY", TEXTURE_UNIT).getSpinnerModel());
|
||||||
scaleV.setEditor(new SpinnerEditor(scaleV));
|
scaleV.setEditor(new SpinnerEditor(scaleV));
|
||||||
mDefault.addEnableComponent(scaleV, false);
|
|
||||||
add(scaleV, "wrap, w 40");
|
add(scaleV, "wrap, w 40");
|
||||||
}
|
}
|
||||||
|
|
||||||
{// Placeholder
|
{// Shine
|
||||||
add(new JLabel(trans.get("AppearanceCfg.lbl.shine")));
|
add(new JLabel(trans.get("AppearanceCfg.lbl.shine")));
|
||||||
IntegerModel shineModel = new IntegerModel(ab, "Shine", 0, 100);
|
IntegerModel shineModel = new IntegerModel(ab, "Shine", 0, 100);
|
||||||
JSpinner spin = new JSpinner(shineModel.getSpinnerModel());
|
JSpinner spin = new JSpinner(shineModel.getSpinnerModel());
|
||||||
JSlider slide = new JSlider(shineModel.getSliderModel());
|
JSlider slide = new JSlider(shineModel.getSliderModel());
|
||||||
mDefault.addEnableComponent(slide, false);
|
|
||||||
mDefault.addEnableComponent(spin, false);
|
|
||||||
|
|
||||||
add(spin, "split 2, w 50");
|
add(spin, "split 2, w 50");
|
||||||
add(slide, "w 100");
|
add(slide, "w 50");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -287,15 +264,13 @@ public class AppearancePanel extends JPanel {
|
|||||||
add(new JLabel(trans.get("AppearanceCfg.lbl.texture.offset")));
|
add(new JLabel(trans.get("AppearanceCfg.lbl.texture.offset")));
|
||||||
|
|
||||||
add(new JLabel("x:"), "split 4");
|
add(new JLabel("x:"), "split 4");
|
||||||
JSpinner offsetU = new JSpinner(new DoubleModel(ab, "OffsetU").getSpinnerModel());
|
JSpinner offsetU = new JSpinner(new DoubleModel(ab, "OffsetU", TEXTURE_UNIT).getSpinnerModel());
|
||||||
offsetU.setEditor(new SpinnerEditor(offsetU));
|
offsetU.setEditor(new SpinnerEditor(offsetU));
|
||||||
mDefault.addEnableComponent(offsetU, false);
|
|
||||||
add(offsetU, "w 40");
|
add(offsetU, "w 40");
|
||||||
|
|
||||||
add(new JLabel("y:"));
|
add(new JLabel("y:"));
|
||||||
JSpinner offsetV = new JSpinner(new DoubleModel(ab, "OffsetV").getSpinnerModel());
|
JSpinner offsetV = new JSpinner(new DoubleModel(ab, "OffsetV", TEXTURE_UNIT).getSpinnerModel());
|
||||||
offsetV.setEditor(new SpinnerEditor(offsetV));
|
offsetV.setEditor(new SpinnerEditor(offsetV));
|
||||||
mDefault.addEnableComponent(offsetV, false);
|
|
||||||
add(offsetV, "wrap, w 40");
|
add(offsetV, "wrap, w 40");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +279,6 @@ public class AppearancePanel extends JPanel {
|
|||||||
EdgeMode[] list = new EdgeMode[EdgeMode.values().length + 1];
|
EdgeMode[] list = new EdgeMode[EdgeMode.values().length + 1];
|
||||||
System.arraycopy(EdgeMode.values(), 0, list, 1, EdgeMode.values().length);
|
System.arraycopy(EdgeMode.values(), 0, list, 1, EdgeMode.values().length);
|
||||||
JComboBox combo = new JComboBox(new EnumModel<EdgeMode>(ab, "EdgeMode", list));
|
JComboBox combo = new JComboBox(new EnumModel<EdgeMode>(ab, "EdgeMode", list));
|
||||||
mDefault.addEnableComponent(combo, false);
|
|
||||||
add(combo);
|
add(combo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,12 +288,10 @@ public class AppearancePanel extends JPanel {
|
|||||||
DoubleModel rotationModel = new DoubleModel(ab, "Rotation", UnitGroup.UNITS_ANGLE);
|
DoubleModel rotationModel = new DoubleModel(ab, "Rotation", UnitGroup.UNITS_ANGLE);
|
||||||
JSpinner rotation = new JSpinner(rotationModel.getSpinnerModel());
|
JSpinner rotation = new JSpinner(rotationModel.getSpinnerModel());
|
||||||
rotation.setEditor(new SpinnerEditor(rotation));
|
rotation.setEditor(new SpinnerEditor(rotation));
|
||||||
mDefault.addEnableComponent(rotation, false);
|
|
||||||
add(rotation, "split 3, w 50");
|
add(rotation, "split 3, w 50");
|
||||||
add(new UnitSelector(rotationModel));
|
add(new UnitSelector(rotationModel));
|
||||||
BasicSlider bs = new BasicSlider(rotationModel.getSliderModel(-Math.PI, Math.PI));
|
BasicSlider bs = new BasicSlider(rotationModel.getSliderModel(-Math.PI, Math.PI));
|
||||||
mDefault.addEnableComponent(bs, false);
|
add(bs, "w 50, wrap");
|
||||||
add(bs, "w 100, wrap");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -59,7 +59,6 @@ public class RocksimConverter {
|
|||||||
try {
|
try {
|
||||||
StorageOptions opts = new StorageOptions();
|
StorageOptions opts = new StorageOptions();
|
||||||
opts.setFileType(StorageOptions.FileType.OPENROCKET);
|
opts.setFileType(StorageOptions.FileType.OPENROCKET);
|
||||||
opts.setCompressionEnabled(true);
|
|
||||||
opts.setSimulationTimeSkip(StorageOptions.SIMULATION_DATA_NONE);
|
opts.setSimulationTimeSkip(StorageOptions.SIMULATION_DATA_NONE);
|
||||||
opts.setExplicitlySet(true);
|
opts.setExplicitlySet(true);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user