Merged honfika changes / GraphFrame, Add font

This commit is contained in:
Jindra Pet��k
2013-08-18 22:23:54 +02:00
4 changed files with 47 additions and 12 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<description>Builds project</description>
<property name="DISTLIBRARIESFULLDIR" value="${DISTRIBUTIONDIR}/${DISTLIBRARIESDIRNAME}"/>
<patternset id="compiler.resources">
<include name="**/?*.properties"/>
<include name="**/?*.properties"/>
<include name="**/?*.bin"/>
<include name="**/?*.xml"/>
<include name="**/?*.txt"/>
@@ -234,15 +234,30 @@ public class GraphFrame extends AppFrame {
return w;
}
}
GraphPanel gp;
int scrollBarWidth;
int scrollBarHeight;
int frameWidthDiff;
int frameHeightDiff;
public GraphFrame(Graph graph, String name) {
setSize(500, 500);
Container cnt = getContentPane();
cnt.setLayout(new BorderLayout());
gp = new GraphPanel(graph);
setTitle(translate("graph") + " " + name);
cnt.add(new JScrollPane(gp));
JScrollPane scrollPane = new JScrollPane(gp);
scrollBarWidth = scrollPane.getVerticalScrollBar().getPreferredSize().width;
scrollBarHeight = scrollPane.getHorizontalScrollBar().getPreferredSize().height;
cnt.add(scrollPane, BorderLayout.CENTER);
pack();
Dimension size = getSize();
Dimension innerSize = getContentPane().getSize();
frameWidthDiff = size.width - innerSize.width;
frameHeightDiff = size.height - innerSize.height;
View.setWindowIcon(this);
@@ -255,24 +270,40 @@ public class GraphFrame extends AppFrame {
Dimension screen = getToolkit().getScreenSize();
Dimension dim = new Dimension(0, 0);
Dimension panDim = gp.getPreferredSize();
if (panDim.width < screen.width) {
dim.width = panDim.width + 10;
// add some magic constants
panDim = new Dimension(panDim.width + 3, panDim.height + 2);
boolean tooHigh = false;
boolean tooWide = false;
if (panDim.width + frameWidthDiff < screen.width) {
dim.width = panDim.width;
} else {
dim.width = screen.width;
tooWide = true;
}
if (panDim.height < screen.height) {
dim.height = panDim.height + 10;
if (panDim.height + frameHeightDiff < screen.height) {
dim.height = panDim.height;
} else {
dim.height = screen.height;
tooHigh = true;
}
if (tooWide) {
dim.height += scrollBarHeight;
dim.height = Math.min(dim.height, screen.height);
}
if (tooHigh) {
dim.width += scrollBarWidth;
dim.width = Math.min(dim.width, screen.width);
}
setVisibleSize(dim);
View.centerScreen(this);
}
private void setVisibleSize(Dimension dim) {
Insets insets = this.getInsets();
setSize(new Dimension(insets.left + insets.right + dim.width,
insets.top + insets.bottom + dim.height));
setSize(new Dimension(dim.width + frameWidthDiff, dim.height + frameHeightDiff));
}
private void drawArrow(Graphics g, int x1, int y1, int x2, int y2) {
@@ -51,7 +51,9 @@ import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Scanner;
import java.util.logging.ConsoleHandler;
@@ -66,6 +68,7 @@ import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.filechooser.FileFilter;
/**
@@ -558,9 +561,9 @@ public class Main {
}
public static void initLang() {
if (Configuration.containsConfig("locale")) {
if (Configuration.containsConfig("locale")) {
Locale.setDefault(Locale.forLanguageTag((String) Configuration.getConfig("locale", "en")));
}
}
UIManager.put("OptionPane.okButtonText", AppStrings.translate("button.ok"));
UIManager.put("OptionPane.yesButtonText", AppStrings.translate("button.yes"));
UIManager.put("OptionPane.noButtonText", AppStrings.translate("button.no"));
@@ -2192,6 +2192,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
char c = newchars.charAt(i);
if (oldchars.indexOf((int) c) == -1) {
f.addCharacter(swf.tags, c, fontSelection.getSelectedItem().toString());
oldchars += c;
}
}
fontAddCharactersField.setText("");