Skip to content
Snippets Groups Projects
Commit 5dcc8657 authored by Tomasz Naskret's avatar Tomasz Naskret
Browse files

Merge branch 'fix6/groups_view_fix' into 'master'

Fix6/groups view fix

See merge request !7
parents 482eec3f 491565e9
No related branches found
No related tags found
1 merge request!7Fix6/groups view fix
No preview for this file type
No preview for this file type
File added
No preview for this file type
File added
No preview for this file type
File added
...@@ -11,10 +11,10 @@ cd .. ...@@ -11,10 +11,10 @@ cd ..
cp TermoPL.jar ./TermoPL_Mac_OS_X cp TermoPL.jar ./TermoPL_Mac_OS_X
cp TermoPL.jar ./TermoPL_Ubuntu cp TermoPL.jar ./TermoPL_Ubuntu
cp TermoPL.jar ./TermoPL_Win64 cp TermoPL.jar ./TermoPL_Win64
rm TermoPL.jar
zip -r ./packages/TermoPL_Mac_OS_X.zip TermoPL_Mac_OS_X zip -r ./packages/TermoPL_Mac_OS_X.zip TermoPL_Mac_OS_X
zip -r ./packages/TermoPL_Ubuntu.zip TermoPL_Ubuntu zip -r ./packages/TermoPL_Ubuntu.zip TermoPL_Ubuntu
zip -r ./packages/TermoPL_Win64.zip TermoPL_Win64 zip -r ./packages/TermoPL_Win64.zip TermoPL_Win64
rm TermoPL.jar
rm -r termopl rm -r termopl
rm -r pl rm -r pl
rm -r quitaboutpreferenceshandler rm -r quitaboutpreferenceshandler
......
...@@ -57,7 +57,7 @@ public class About extends JPanel ...@@ -57,7 +57,7 @@ public class About extends JPanel
vbox.add(Box.createVerticalStrut(16)); vbox.add(Box.createVerticalStrut(16));
hbox = Box.createHorizontalBox(); hbox = Box.createHorizontalBox();
hbox.add(Box.createHorizontalGlue()); hbox.add(Box.createHorizontalGlue());
label = new JLabel("Version 6.0.4"); label = new JLabel("Version 6.0.5");
label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12)); label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
hbox.add(label); hbox.add(label);
hbox.add(Box.createHorizontalGlue()); hbox.add(Box.createHorizontalGlue());
......
...@@ -15,6 +15,8 @@ public class GroupsView extends JPanel ...@@ -15,6 +15,8 @@ public class GroupsView extends JPanel
private static final int CHILD = 2; private static final int CHILD = 2;
private TermoPLDocument doc; private TermoPLDocument doc;
private TermComparator comp;
private SimpleComparator simpleComp;
private JSplitPane splitPane; private JSplitPane splitPane;
private HierarchyPanel hierarchyPanel; private HierarchyPanel hierarchyPanel;
private RelatedPanel relatedPanel; private RelatedPanel relatedPanel;
...@@ -24,6 +26,8 @@ public class GroupsView extends JPanel ...@@ -24,6 +26,8 @@ public class GroupsView extends JPanel
public GroupsView(TermoPLDocument document) public GroupsView(TermoPLDocument document)
{ {
doc = document; doc = document;
comp = new TermComparator();
simpleComp = new SimpleComparator();
setLayout(new BorderLayout()); setLayout(new BorderLayout());
arrangeComponents(); arrangeComponents();
...@@ -95,6 +99,12 @@ public class GroupsView extends JPanel ...@@ -95,6 +99,12 @@ public class GroupsView extends JPanel
else infoPanel.setWarning("Term is not selected."); else infoPanel.setWarning("Term is not selected.");
} }
public void sort(LinkedList<String> terms, boolean simple)
{
if (simple) Collections.sort(terms, simpleComp);
else Collections.sort(terms, comp);
}
public void reset() public void reset()
{ {
setData(null); setData(null);
...@@ -163,6 +173,7 @@ public class GroupsView extends JPanel ...@@ -163,6 +173,7 @@ public class GroupsView extends JPanel
int x, y, dy; int x, y, dy;
add(node); add(node);
if (parents != null) sort(parents, false);
dim = node.getPreferredSize(); dim = node.getPreferredSize();
node.setBounds(16, offsetY, dim.width, dim.height); node.setBounds(16, offsetY, dim.width, dim.height);
dy = dim.height; dy = dim.height;
...@@ -250,13 +261,15 @@ public class GroupsView extends JPanel ...@@ -250,13 +261,15 @@ public class GroupsView extends JPanel
if (maxWidth < x) maxWidth = x; if (maxWidth < x) maxWidth = x;
} }
offsetY = node.getY() + dy + 8; offsetY = node.getY() + dy + 8;
if (children != null) if (children != null) {
sort(children, false);
for (String t : children) { for (String t : children) {
TermEx term = (TermEx)doc.getTermMap().get(t); TermEx term = (TermEx)doc.getTermMap().get(t);
arrangeNodes(node, term); arrangeNodes(node, term);
} }
} }
}
public void calcSize() public void calcSize()
{ {
...@@ -296,12 +309,27 @@ public class GroupsView extends JPanel ...@@ -296,12 +309,27 @@ public class GroupsView extends JPanel
public void arrangeComponents() public void arrangeComponents()
{ {
addLabel(term, TermoPL.preferences.boldFont, type);
LinkedList<String> equiv = term.getEquivalentTerms(); LinkedList<String> equiv = term.getEquivalentTerms();
String skipID = null;
boolean addType = true;
if (type == ROOT) {
addLabel(term, TermoPL.preferences.boldFont, type);
skipID = term.id;
addType = false;
}
else if (equiv == null) addLabel(term, TermoPL.preferences.boldFont, type);
if (equiv != null) { if (equiv != null) {
for (String e : equiv) sort(equiv, true);
if (e != term.id) addLabel((TermEx)doc.getTermMap().get(e)); for (String e : equiv) {
if (e != skipID) {
if (addType) {
addLabel((TermEx)doc.getTermMap().get(e), TermoPL.preferences.boldFont, type);
addType = false;
}
else addLabel((TermEx)doc.getTermMap().get(e));
}
}
} }
} }
...@@ -748,4 +776,53 @@ public class GroupsView extends JPanel ...@@ -748,4 +776,53 @@ public class GroupsView extends JPanel
} }
private class SimpleComparator implements Comparator<String>
{
public int compare(String s1, String s2)
{
double v1 = doc.getTermMap().get(s1).cvalue;
double v2 = doc.getTermMap().get(s2).cvalue;
if (v1 < v2) return 1;
if (v1 > v2) return -1;
return 0;
}
}
private class TermComparator implements Comparator<String>
{
public int compare(String s1, String s2)
{
TermEx t1 = (TermEx)doc.getTermMap().get(s1);
TermEx t2 = (TermEx)doc.getTermMap().get(s2);
double v1, v2;
if (t1.getEquivalentTerms() == null) v1 = t1.cvalue;
else {
v1 = 0.0;
for (String s : t1.getEquivalentTerms()) {
TermEx t = (TermEx)doc.getTermMap().get(s);
if (t.cvalue > v1) v1 = t.cvalue;
}
}
if (t2.getEquivalentTerms() == null) v2 = t2.cvalue;
else {
v2 = 0.0;
for (String s : t2.getEquivalentTerms()) {
TermEx t = (TermEx)doc.getTermMap().get(s);
if (t.cvalue > v2) v2 = t.cvalue;
}
}
if (v1 < v2) return 1;
if (v1 > v2) return -1;
return 0;
}
}
} }
...@@ -177,23 +177,37 @@ public class TermEx extends Term ...@@ -177,23 +177,37 @@ public class TermEx extends Term
public LinkedList<String> collectChildren(HashMap<String, Term> termMap) public LinkedList<String> collectChildren(HashMap<String, Term> termMap)
{ {
if (equivTerms == null) return children;
else {
LinkedList<String> allChildren = new LinkedList<String>(); LinkedList<String> allChildren = new LinkedList<String>();
if (equivTerms == null) allChildren = children;
else {
allChildren = new LinkedList<String>();
for (String e : equivTerms) { for (String e : equivTerms) {
TermEx t = (TermEx)termMap.get(e); TermEx t = (TermEx)termMap.get(e);
LinkedList<String> clist = t.getChildren(); LinkedList<String> clist = t.getChildren();
if (clist != null) { if (clist != null) {
for (String c : clist) { for (String c : clist) {
if (!allChildren.contains(c)) allChildren.add(c); TermEx tc = (TermEx)termMap.get(c);
if (tc.equivTerms != null) {
boolean found = false;
for (String ec : tc.equivTerms) {
if (allChildren.contains(ec)) {
found = true;
break;
} }
} }
if (!found) allChildren.add(c);
} }
return allChildren; else if (!allChildren.contains(c)) allChildren.add(c);
} }
} }
}
}
return allChildren;
}
public LinkedList<Pair<String, LinkedList<WordReplacement>>> collectRelated(HashMap<String, Term> termMap) public LinkedList<Pair<String, LinkedList<WordReplacement>>> collectRelated(HashMap<String, Term> termMap)
{ {
......
...@@ -434,7 +434,7 @@ public class WordNet ...@@ -434,7 +434,7 @@ public class WordNet
case 141: case 141:
case 142: case 142:
case 169: case 169:
case 244: return "interparadigmatic synonymy"; case 244: return "inter-paradigmatic synonymy";
default: return "?"; default: return "?";
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment