fix logic issues and find nearest point

This commit is contained in:
Ben Fry
2015-08-21 15:15:51 -04:00
parent 889b9352ec
commit 345e043527
2 changed files with 42 additions and 33 deletions
+13 -12
View File
@@ -6,14 +6,6 @@ X https://github.com/processing/processing/issues/3685
X setFill() on PShape in Java2D throws ArrayIndexOutOfBoundsException
X https://github.com/processing/processing/issues/3677
cleaning
X How do images behave when pixelDensity(2) is set?
X https://github.com/processing/processing/issues/3364
X retina sketches slow to start
X https://github.com/processing/processing/issues/2357
X zero alpha values still a problem with retina renderer
X https://github.com/processing/processing/issues/2030
jakub
X keyTyped() not firing with P2D and P3D
X https://github.com/processing/processing/issues/3582
@@ -31,6 +23,19 @@ X added note about AIOOBE seen earlier
X Update LowLevelGL to use VBOs
X https://github.com/processing/processing-docs/pull/289
cleaning
X How do images behave when pixelDensity(2) is set?
X https://github.com/processing/processing/issues/3364
X retina sketches slow to start
X https://github.com/processing/processing/issues/2357
X zero alpha values still a problem with retina renderer
X https://github.com/processing/processing/issues/2030
X fullScreen(SPAN) reported not working (cannot reproduce)
X probably need to re-query for displays each time opening prefs
X what happens when a screen is added after p5 has started?
X https://github.com/processing/processing/issues/3381
X fixed in beta 1
known issues
_ P2D and P3D windows behave strangely when larger than the screen size
@@ -128,10 +133,6 @@ _ https://bugs.openjdk.java.net/browse/JDK-8027391
_ test with JG's 13" retina laptop
_ Ubuntu Unity prevents full screen from working properly
_ https://github.com/processing/processing/issues/3158
_ fullScreen(SPAN) reported not working (cannot reproduce)
X probably need to re-query for displays each time opening prefs
X what happens when a screen is added after p5 has started?
_ https://github.com/processing/processing/issues/3381
graphics
+29 -21
View File
@@ -158,17 +158,13 @@ public class MarkerColumn extends JPanel {
/** Find out which error/warning the user has clicked and scroll to it */
void scrollToMarkerAt(final int y) {
private void scrollToMarkerAt(final int y) {
try {
new SwingWorker<Object, Object>() {
new SwingWorker() {
protected Object doInBackground() throws Exception {
for (LineMarker m : errorPoints) {
// -2 and +2 are extra allowance, clicks in the
// vicinity of the markers register that way
if (Math.abs(y - m.getY()) < 3) {
editor.getErrorChecker().scrollToErrorLine(m.getProblem());
return null;
}
LineMarker m = findClosestMarker(y);
if (m != null) {
editor.getErrorChecker().scrollToErrorLine(m.getProblem());
}
return null;
}
@@ -180,20 +176,18 @@ public class MarkerColumn extends JPanel {
/** Show tooltip on hover. */
void showMarkerHover(final int y) {
private void showMarkerHover(final int y) {
try {
new SwingWorker<Object, Object>() {
new SwingWorker() {
protected Object doInBackground() throws Exception {
for (LineMarker m : errorPoints) {
if (Math.abs(y - m.getY()) < 3) {
Problem p = m.getProblem();
String kind = p.isError() ?
Language.text("editor.status.error") :
Language.text("editor.status.warning");
setToolTipText(kind + ": " + p.getMessage());
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
break;
}
LineMarker m = findClosestMarker(y);
if (m != null) {
Problem p = m.getProblem();
String kind = p.isError() ?
Language.text("editor.status.error") :
Language.text("editor.status.warning");
setToolTipText(kind + ": " + p.getMessage());
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
return null;
}
@@ -204,6 +198,20 @@ public class MarkerColumn extends JPanel {
}
private LineMarker findClosestMarker(final int y) {
LineMarker closest = null;
int closestDist = Integer.MAX_VALUE;
for (LineMarker m : errorPoints) {
int dist = Math.abs(y - m.getY());
if (dist < 3 && dist < closestDist) {
closest = m;
closestDist = dist;
}
}
return closest;
}
public Dimension getPreferredSize() {
return new Dimension(WIDE, super.getPreferredSize().height);
}