# value for bootstrap support)
#
# Font family name: 'font_family':
-# Example: 'font_family: Sans,Helvetica'
+# Example: 'font_family: Arial_Unicode_MS,Dialog,SansSerif,Sans,Arial,Helvetica'
# It is advisable to use more than one value for font_family (in
# decreasing order of preference). Font family names have to be
# comma separated (no spaces). Spaces in font names have to be
-# replaced by underscores (e.g. 'Times_New_Roman').
+# replaced by underscores (e.g. 'Arial_Unicode_MS').
#
# Font size: 'font_size':
# Example: 'font_size: 10'
min_confidence_value: 0.0
-font_family: SansSerif,Sans-serif,Sans,Dialog,Tahoma,Helvetica,Arial,Verdana
+font_family: Arial_Unicode_MS,Dialog,SansSerif,Sans,Arial,Helvetica
font_size: 10
font_size_min: 2
font_size_max: 20
<property name="src.dir" value="src" />
<property name="classes.dir" value="classes" />
<property name="jars.dir" value="resources" />
- <property name="itextjar" value="${jars.dir}/itextpdf-5.1.0.jar" />
+ <property name="itextjar" value="${jars.dir}/itextpdf-5.5.9.jar" />
<property name="commonscodecjar" value="${jars.dir}/commons-codec-1.5.jar" />
<property name="openchartjar" value="${jars.dir}/openchart.jar" />
<property name="forester_jar" value="forester.jar" />
final static boolean __ALLOW_PHYLOGENETIC_INFERENCE = true;
public final static boolean __RELEASE = false; // TODO remove me
public final static boolean __SNAPSHOT_RELEASE = false; // TODO remove me
- public final static boolean __SYNTH_LF = false; // TODO remove me
public final static String PRG_NAME = "Archaeopteryx";
final static String VERSION = "0.9912 beta";
- final static String PRG_DATE = "160629";
+ final static String PRG_DATE = "160631";
final static String DEFAULT_CONFIGURATION_FILE_NAME = "_aptx_configuration_file";
final static String[] DEFAULT_FONT_CHOICES = {
- "SansSerif", "Sans-serif", "Sans", "Dialog", "Lucida Sans", "Tahoma", "Helvetica", "Arial", "Verdana" };
+ "Arial Unicode MS", "Dialog", "SansSerif", "Sans", "Arial", "Helvetica" };
final static boolean VERBOSE_DEFAULT = false;
final static int DOMAIN_STRUCTURE_DEFAULT_WIDTH = 100;
final static String AUTHOR_EMAIL = "phyloxml@gmail.com";
import javax.swing.WindowConstants;\r
import javax.swing.event.ChangeEvent;\r
import javax.swing.event.ChangeListener;\r
-import javax.swing.plaf.synth.SynthLookAndFeel;\r
\r
import org.forester.analysis.TaxonomyDataManager;\r
import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;\r
throw new IllegalArgumentException( "configuration is null" );\r
}\r
try {\r
- boolean synth_exception = false;\r
- if ( AptxConstants.__SYNTH_LF ) {\r
- try {\r
- final SynthLookAndFeel synth = new SynthLookAndFeel();\r
- synth.load( MainFrameApplication.class.getResourceAsStream( "/resources/synth_look_and_feel_1.xml" ),\r
- MainFrameApplication.class );\r
- UIManager.setLookAndFeel( synth );\r
- }\r
- catch ( final Exception ex ) {\r
- synth_exception = true;\r
- ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME,\r
- "could not create synth look and feel: "\r
- + ex.getLocalizedMessage() );\r
- }\r
+ if ( _configuration.isUseNativeUI() ) {\r
+ UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );\r
}\r
- if ( !AptxConstants.__SYNTH_LF || synth_exception ) {\r
- if ( _configuration.isUseNativeUI() ) {\r
- UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );\r
- }\r
- else {\r
- UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );\r
- }\r
+ else {\r
+ UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );\r
}\r
- //UIManager.setLookAndFeel( "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" );\r
}\r
catch ( final UnsupportedLookAndFeelException e ) {\r
AptxUtil.dieWithSystemError( "unsupported look and feel: " + e.toString() );\r
List<MolecularSequence> seqs = null;\r
if ( ( file != null ) && !file.isDirectory() && ( result == JFileChooser.APPROVE_OPTION ) ) {\r
try {\r
- if ( FastaParser.isLikelyFasta( new FileInputStream( file ) ) ) {\r
- seqs = FastaParser.parse( new FileInputStream( file ) );\r
+ final FileInputStream fis1 = new FileInputStream( file );\r
+ if ( FastaParser.isLikelyFasta( fis1 ) ) {\r
+ final FileInputStream fis2 = new FileInputStream( file );\r
+ seqs = FastaParser.parse( fis2 );\r
+ try {\r
+ fis2.close();\r
+ }\r
+ catch ( final Exception e ) {\r
+ // Ignore.\r
+ }\r
}\r
else {\r
JOptionPane.showMessageDialog( this,\r
JOptionPane.ERROR_MESSAGE );\r
return;\r
}\r
+ try {\r
+ fis1.close();\r
+ }\r
+ catch ( final Exception e ) {\r
+ // Ignore.\r
+ }\r
}\r
catch ( final MsaFormatException e ) {\r
setArrowCursor();\r
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
import org.forester.phylogeny.Phylogeny;
import org.forester.util.ForesterUtil;
+import com.itextpdf.awt.DefaultFontMapper;
+import com.itextpdf.awt.DefaultFontMapper.BaseFontParameters;
+import com.itextpdf.awt.PdfGraphics2D;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.FontFactory;
import com.itextpdf.text.Rectangle;
-import com.itextpdf.text.pdf.DefaultFontMapper;
+import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfWriter;
*
* See: http://www.lowagie.com/iText/
*
- * Current version: iText-2.1.7
+ * Current version: iText-5.5.9
*/
final class PdfExporter {
PdfWriter writer = null;
try {
writer = PdfWriter.getInstance( document, new FileOutputStream( file_name ) );
+
}
catch ( final DocumentException e ) {
throw new IOException( e );
final DefaultFontMapper mapper = new DefaultFontMapper();
FontFactory.registerDirectories();
if ( ForesterUtil.isWindows() ) {
- mapper.insertDirectory( "C:\\WINDOWS\\Fonts\\" );
+ mapper.insertDirectory( "c:/windows/fonts" );
}
else if ( ForesterUtil.isMac() ) {
mapper.insertDirectory( "/Library/Fonts/" );
mapper.insertDirectory( "/usr/share/fonts/default/TrueType/" );
mapper.insertDirectory( "/usr/share/fonts/default/Type1/" );
}
+ enableUnicode( mapper );
final PdfContentByte cb = writer.getDirectContent();
- final Graphics2D g2 = cb.createGraphics( width, height, mapper );
+
+ final Graphics2D g2 = new PdfGraphics2D(cb, width, height, mapper);
+
try {
tree_panel.paintPhylogeny( g2, true, false, width, height, 0, 0 );
}
}
return msg;
}
+
+ private final static void enableUnicode( final DefaultFontMapper mapper ) {
+ final Map<String, DefaultFontMapper.BaseFontParameters> map = mapper.getMapper();
+ for (final Iterator<String> i = map.keySet().iterator(); i.hasNext();) {
+ final String name = i.next();
+ final String name_lc = name.toLowerCase();
+ if ( name_lc.contains( "unicode" ) || name_lc.equals( "dialog" ) ) {
+ final BaseFontParameters pfps = map.get(name);
+ try {
+ pfps.encoding = BaseFont.IDENTITY_H;
+ pfps.embedded = true;
+ }
+ catch ( Exception e ) {
+ //Ignore.
+ }
+ }
+ }
+ }
+
+ /* not used currently
+ static FontMapper arial_uni = new FontMapper() {
+ public BaseFont awtToPdf(Font font) {
+ System.out.println( font.toString() );
+ try {
+ return BaseFont.createFont(
+ "c:/windows/fonts/arialuni.ttf",
+ BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
+ }
+ catch (DocumentException e) {
+ e.printStackTrace();
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ public Font pdfToAwt( BaseFont arg0, int arg1 ) {
+ return null;
+ }
+ };
+ */
}
static final int BOLD_AND_ITALIC = Font.BOLD + Font.ITALIC;
final static float FONT_SIZE_CHANGE_STEP = 1.0f;
final static float SMALL_FONTS_BASE = 8;
- private final static String DEFAULT_FONT = "Verdana";
+ private final static String DEFAULT_FONT = "Arial Unicode MS";
private Font _base_font;
private boolean _decreased_size_by_system = false;
private FontMetrics _fm_large;
private float _y_distance = 0.0f;
private int _length_of_longest_text;
private int _longest_domain;
- // private Image offscreenImage;
- // private Graphics offscreenGraphics;
- // private Dimension offscreenDimension;
static {
final DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setDecimalSeparator( '.' );
setOvXDistance( ov_xdist );
final double height = _phylogeny.getHeight();
if ( height > 0 ) {
- final float corr = ( float ) ( ( x - TreePanel.MOVE - getLongestExtNodeInfo() - getXdistance() ) / height );
+ final float corr = ( float ) ( ( x - ( 2.0 * TreePanel.MOVE ) - getLongestExtNodeInfo() - getXdistance() ) / height );
setXcorrectionFactor( corr > 0 ? corr : 0 );
final float ov_corr = ( float ) ( ( getOvMaxWidth() - getOvXDistance() ) / height );
setOvXcorrectionFactor( ov_corr > 0 ? ov_corr : 0 );
if ( ( _phylogeny == null ) || _phylogeny.isEmpty() ) {
return;
}
- int max_length = ForesterUtil.roundToInt( ( getSize().getWidth() - MOVE )
+ int max_length = ForesterUtil.roundToInt( ( getSize().getWidth() - 2 * MOVE )
* AptxConstants.EXT_NODE_INFO_LENGTH_MAX_RATIO );
if ( max_length < 40 ) {
max_length = 40;
_longest_ext_node_info = longest;
}
_length_of_longest_text = calcLengthOfLongestText();
+ System.out.println( "_length_of_longest_text=" + _length_of_longest_text );
+ //~~
}
final void calculateScaleDistance() {
+ getLongestExtNodeInfo()
+ ForesterUtil
.roundToInt( ( getXcorrectionFactor() * getPhylogeny().getHeight() ) + getXdistance() );
+
}
else {
if ( !isNonLinedUpCladogram() && !isUniformBranchLengthsForCladogram() ) {