Always save using .zip container format. Removed the "use compression"
option from the StorageOptionChooser.
This commit is contained in:
parent
1bbef243ac
commit
7db51b9b65
@ -1063,8 +1063,6 @@ StorageOptChooser.lbl.longC1 = <html>Store only the values shown in the summary
|
|||||||
StorageOptChooser.lbl.longC2 = This results in the smallest files.
|
StorageOptChooser.lbl.longC2 = This results in the smallest files.
|
||||||
StorageOptChooser.checkbox.IncludeDecals = Include decals
|
StorageOptChooser.checkbox.IncludeDecals = Include decals
|
||||||
StorageOptChooser.lbl.IncludeDecals = "Including decals will produce a compressed zip file"
|
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:
|
||||||
|
@ -16,8 +16,6 @@ public class StorageOptions implements Cloneable {
|
|||||||
|
|
||||||
private boolean includeDecals = false;
|
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;
|
||||||
@ -38,14 +36,6 @@ public class StorageOptions implements Cloneable {
|
|||||||
this.includeDecals = 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,7 +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.getDefaultStorageOptions().setIncludeDecals(true);
|
||||||
doc.getDecalRegistry().setIsZipFile(true);
|
doc.getDecalRegistry().setIsZipFile(true);
|
||||||
return doc;
|
return doc;
|
||||||
|
@ -146,16 +146,6 @@ 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.
|
|
||||||
if (!options.isIncludeDecals()) {
|
|
||||||
saveInternal(output,document,options);
|
|
||||||
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 ...
|
/* if we want a directory ...
|
||||||
String path = fileName;
|
String path = fileName;
|
||||||
int dotlocation = fileName.lastIndexOf('.');
|
int dotlocation = fileName.lastIndexOf('.');
|
||||||
|
@ -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();
|
||||||
|
@ -39,7 +39,6 @@ public class StorageOptionChooser extends JPanel {
|
|||||||
|
|
||||||
private JSpinner timeSpinner;
|
private JSpinner timeSpinner;
|
||||||
|
|
||||||
private JCheckBox compressButton;
|
|
||||||
private JCheckBox decalButton;
|
private JCheckBox decalButton;
|
||||||
|
|
||||||
private JLabel estimateLabel;
|
private JLabel estimateLabel;
|
||||||
@ -130,14 +129,6 @@ public class StorageOptionChooser extends JPanel {
|
|||||||
decalButton.addActionListener(actionUpdater);
|
decalButton.addActionListener(actionUpdater);
|
||||||
this.add(decalButton, "spanx, wrap para");
|
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("");
|
||||||
@ -176,8 +167,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());
|
decalButton.setSelected(opts.isIncludeDecals());
|
||||||
|
|
||||||
updateEstimate();
|
updateEstimate();
|
||||||
@ -198,7 +187,6 @@ public class StorageOptionChooser extends JPanel {
|
|||||||
opts.setSimulationTimeSkip(t);
|
opts.setSimulationTimeSkip(t);
|
||||||
|
|
||||||
opts.setIncludeDecals(decalButton.isSelected());
|
opts.setIncludeDecals(decalButton.isSelected());
|
||||||
opts.setCompressionEnabled(compressButton.isSelected());
|
|
||||||
|
|
||||||
opts.setExplicitlySet(true);
|
opts.setExplicitlySet(true);
|
||||||
}
|
}
|
||||||
|
@ -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