Skip to content

Commit

Permalink
Some small changes (#52)
Browse files Browse the repository at this point in the history
* GH-51 Changes MarkupAnnotation toString, adds getControllers, sync annotationComponents on refresh
* GH-51 Synchronizes after nullcheck
* GH-51 Fixes AnnotationComparator page sorting
* GH-51 Use Integer.compare for comparator
  • Loading branch information
gtache committed Mar 4, 2020
1 parent 25234f1 commit f99be67
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,6 @@ public void setSubject(String subject) {
}

public String toString() {
return getTitleText();
return getPObjectReference() + " - " + getTitleText() + " - " + getContents();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import javax.swing.*;
import java.net.URL;
import java.util.Collection;
import java.util.List;
import java.util.prefs.Preferences;

Expand Down Expand Up @@ -51,4 +52,6 @@ void quit(Controller controller, JFrame viewer,
Preferences preferences);

ViewerPropertiesManager getProperties();

Collection<Controller> getControllers();
}
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,7 @@ class AnnotationComparator implements Comparator<MarkupAnnotation> {
@Override
public int compare(MarkupAnnotation o1, MarkupAnnotation o2) {
if (MarkupAnnotationPanel.SortColumn.PAGE.equals(sortColumn)) {
if (o1.getPageIndex() > o2.getPageIndex()) {
return 1;
} else if (o1.getPageIndex() > o2.getPageIndex()) {
return -1;
} else {
return 0;
}
return Integer.compare(o1.getPageIndex(), o2.getPageIndex());
} else if (MarkupAnnotationPanel.SortColumn.AUTHOR.equals(sortColumn)) {
String author1 = o1.getTitleText();
String author2 = o2.getTitleText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,17 @@ public void updateView(String propertyConstant, Object oldValue, Object newValue
if (PropertyConstants.DOCUMENT_VIEW_ROTATION_CHANGE.equals(propertyConstant) ||
PropertyConstants.DOCUMENT_VIEW_ZOOM_CHANGE.equals(propertyConstant)) {
if (annotationComponents != null) {
for (AbstractAnnotationComponent comp : annotationComponents) {
comp.validate();
synchronized (annotationComponents) {
for (AbstractAnnotationComponent comp : annotationComponents) {
comp.validate();
}
}
}
if (destinationComponents != null) {
for (DestinationComponent comp : destinationComponents) {
comp.validate();
synchronized (destinationComponents) {
for (DestinationComponent comp : destinationComponents) {
comp.validate();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.awt.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.ResourceBundle;
import java.util.prefs.Preferences;
Expand Down Expand Up @@ -95,6 +96,9 @@ public long getNumberOfWindows() {
return newWindowInvocationCounter;
}

public Collection<Controller> getControllers() {
return controllers;
}

public void newWindow(final String location) {
Controller controller = commonWindowCreation();
Expand Down

0 comments on commit f99be67

Please sign in to comment.