Changeset 1171 for trunk/src/org/expeditee/gui/DisplayController.java
- Timestamp:
- 09/28/18 09:33:46 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/DisplayController.java
r1157 r1171 170 170 private static void fireFrameChanged() 171 171 { 172 for (DisplayObserver observer : _displayObservers) observer.frameChanged(); 172 for (DisplayObserver observer : _displayObservers) { 173 observer.frameChanged(); 174 } 173 175 } 174 176 … … 187 189 public static void addDisplayObserver(DisplayObserver observer) 188 190 { 189 if (observer == null) throw new NullPointerException("observer"); 191 if (observer == null) { 192 throw new NullPointerException("observer"); 193 } 190 194 191 195 _displayObservers.add(observer); … … 205 209 public static void removeDisplayObserver(DisplayObserver observer) 206 210 { 207 if (observer == null) throw new NullPointerException("observer"); 211 if (observer == null) { 212 throw new NullPointerException("observer"); 213 } 208 214 209 215 _displayObservers.remove(observer); … … 231 237 int size = Math.round(text.getSize()); 232 238 233 if (allowClearSelection && !isShiftDown && text.hasSelection()) text.clearSelection(); 239 if (allowClearSelection && !isShiftDown && text.hasSelection()) { 240 text.clearSelection(); 241 } 234 242 235 243 Point newMouse = text.moveCursor(cursorMovement, DisplayController.getFloatMouseX(), EcosystemManager.getInputManager().getCursorPosition().getY(), isShiftDown, isCtrlDown); … … 257 265 258 266 if (!newSize && _cursorType == Item.TEXT_CURSOR) { 259 if (cursorMovement != 0) 267 if (cursorMovement != 0) { 260 268 DisplayController.setCursorPosition(newMouse, false); 269 } 261 270 return; 262 271 } … … 330 339 { 331 340 // Avoid flicker when not changing 332 if (type == _cursorType) return; 341 if (type == _cursorType) { 342 return; 343 } 333 344 334 345 _cursorType = type; … … 463 474 464 475 // check that the stack is not empty 465 if (visitedFrames.size() > 0) return visitedFrames.peek(); 476 if (visitedFrames.size() > 0) { 477 return visitedFrames.peek(); 478 } 466 479 467 480 // if the stack is empty, return null … … 472 485 public static void setTransition(Frame frame, FrameTransition transition) 473 486 { 474 if (frame == null) return; 487 if (frame == null) { 488 return; 489 } 475 490 TwinFramesSide side = getSideFrameIsOn(frame); 476 491 setTransition(side, transition); … … 480 495 private static void setTransition(TwinFramesSide side, FrameTransition transition) 481 496 { 482 if (side == null) return; 497 if (side == null) { 498 return; 499 } 483 500 484 501 _transitions[side.ordinal()] = transition; … … 488 505 private static FrameTransition getTransition(TwinFramesSide side) 489 506 { 490 if (side == null) return null; 507 if (side == null) { 508 return null; 509 } 491 510 492 511 return _transitions[side.ordinal()]; … … 499 518 public static void setCurrentFrame(Frame frame, boolean incrementStats) 500 519 { 501 if (frame == null) return; 520 if (frame == null) { 521 return; 522 } 502 523 503 524 // If one of the sides doesn't have a frame yet, give it this one … … 520 541 521 542 // Update stats 522 if (incrementStats) SessionStats.AccessedFrame(); 543 if (incrementStats) { 544 SessionStats.AccessedFrame(); 545 } 523 546 524 547 // Invalidate free items … … 571 594 // Get all overlayed frames seen by the next frame 572 595 for (Overlay o : frame.getOverlays()) { 573 if (!nextOnlyOverlays.contains(o.Frame)) 596 if (!nextOnlyOverlays.contains(o.Frame)) { 574 597 nextOnlyOverlays.add(o.Frame); 598 } 575 599 } 576 600 … … 578 602 if (getCurrentFrame() != null) { 579 603 for (Overlay o : getCurrentFrame().getOverlays()) { 580 if (!currentOnlyOverlays.contains(o.Frame)) 604 if (!currentOnlyOverlays.contains(o.Frame)) { 581 605 currentOnlyOverlays.add(o.Frame); 606 } 582 607 } 583 608 } … … 605 630 // possible non-shared overlays 606 631 items = getCurrentFrame().getAllItems(); 607 for (Frame f : seen) 632 for (Frame f : seen) { 608 633 items.removeAll(f.getAllItems()); 634 } 609 635 610 636 // Notify items that they are hidden … … 687 713 688 714 // If there's only a right frame, that's the current side 689 if (!sideHasFrame(LEFT) && sideHasFrame(RIGHT)) return RIGHT; 715 if (!sideHasFrame(LEFT) && sideHasFrame(RIGHT)) { 716 return RIGHT; 717 } 690 718 691 719 // In any other case the left side is the current side … … 696 724 private static TwinFramesSide getOppositeSide() 697 725 { 698 if (getCurrentSide() == LEFT) return RIGHT; 726 if (getCurrentSide() == LEFT) { 727 return RIGHT; 728 } 699 729 700 730 return LEFT; … … 706 736 // Loop through both sides 707 737 for (TwinFramesSide side : TwinFramesSide.values()) { 708 if (getFrameOnSide(side) == frame) return side; 738 if (getFrameOnSide(side) == frame) { 739 return side; 740 } 709 741 } 710 742 … … 715 747 public static Frame getFrameOnSide(TwinFramesSide side) 716 748 { 717 if (side == null) return null; 749 if (side == null) { 750 return null; 751 } 718 752 719 753 return _currentFrames[side.ordinal()]; … … 747 781 public static Line getTwinFramesSeparatorLine() 748 782 { 749 if (!isTwinFramesOn()) return null; 783 if (!isTwinFramesOn()) { 784 return null; 785 } 750 786 751 787 int x = getTwinFramesSeparatorX(); … … 760 796 { 761 797 // No message bay in audience mode 762 if (isAudienceMode()) return null; 798 if (isAudienceMode()) { 799 return null; 800 } 763 801 764 802 int separatorThickness = (int) SEPARATOR_STROKE.thickness; … … 778 816 public static float getFloatMouseX() 779 817 { 780 return (float)getMouseX();818 return getMouseX(); 781 819 } 782 820 … … 820 858 public static float getFloatMouseY() 821 859 { 822 return (float)getMouseY();860 return getMouseY(); 823 861 } 824 862 … … 857 895 858 896 // do not get a cached version (in case it is in the other window) 859 if (isTwinFramesOn()) FrameIO.SuspendCache(); 897 if (isTwinFramesOn()) { 898 FrameIO.SuspendCache(); 899 } 860 900 861 901 Frame frame = FrameIO.LoadFrame(removeFromBack()); … … 913 953 914 954 // do not get a cached version (in case it is in the other window) 915 if (isTwinFramesOn()) 955 if (isTwinFramesOn()) { 916 956 FrameIO.SuspendCache(); 957 } 917 958 Frame frame = FrameIO.LoadFrame(getBackedUpFrames(side).pop()); 918 959 // If the top frame on the backup stack is the current frame go back … … 964 1005 965 1006 // Update the sizes of the displayed frames 966 if (getCurrentFrame() != null) getCurrentFrame().refreshSize(); 967 if (getOppositeFrame() != null) getOppositeFrame().refreshSize(); 1007 if (getCurrentFrame() != null) { 1008 getCurrentFrame().refreshSize(); 1009 } 1010 if (getOppositeFrame() != null) { 1011 getOppositeFrame().refreshSize(); 1012 } 968 1013 969 1014 requestRefresh(false); … … 979 1024 public static void Reload(TwinFramesSide side) 980 1025 { 981 if (side == null) return; 1026 if (side == null) { 1027 return; 1028 } 982 1029 983 1030 FrameIO.SuspendCache(); … … 1029 1076 private static void setFrameOnSide(Frame frame, TwinFramesSide side) 1030 1077 { 1031 if (side == null) return; 1078 if (side == null) { 1079 return; 1080 } 1032 1081 1033 1082 _currentFrames[side.ordinal()] = frame; … … 1037 1086 private static Stack<String> getVisitedFrames(TwinFramesSide side) 1038 1087 { 1039 if (side == null) return null; 1088 if (side == null) { 1089 return null; 1090 } 1040 1091 1041 1092 return _visitedFrames[side.ordinal()]; … … 1045 1096 private static Stack<String> getBackedUpFrames(TwinFramesSide side) 1046 1097 { 1047 if (side == null) return null; 1098 if (side == null) { 1099 return null; 1100 } 1048 1101 1049 1102 return _backedUpFrames[side.ordinal()]; … … 1087 1140 1088 1141 // Turn off x-ray mode if it's on 1089 if (_xrayMode) ToggleXRayMode(); 1142 if (_xrayMode) { 1143 ToggleXRayMode(); 1144 } 1090 1145 1091 1146 // Toggle audience mode … … 1105 1160 { 1106 1161 // Turn off x-ray mode if it is on 1107 if (_audienceMode) ToggleAudienceMode(); 1162 if (_audienceMode) { 1163 ToggleAudienceMode(); 1164 } 1108 1165 1109 1166 _xrayMode = !_xrayMode; … … 1194 1251 public static void invalidateItem(Item damagedItem, Bounds toRepaint) 1195 1252 { 1196 if (toRepaint == null) return; 1253 if (toRepaint == null) { 1254 return; 1255 } 1197 1256 1198 1257 // Only add area to repaint if item is visible... … … 1239 1298 1240 1299 // No damaged areas 1241 if (useInvalidation && clip.isFullyClipped()) return true; 1300 if (useInvalidation && clip.isFullyClipped()) { 1301 return true; 1302 } 1242 1303 1243 1304 GraphicsManager g = EcosystemManager.getGraphicsManager(); … … 1251 1312 leftClip = clip.clone().intersectWith(getLeftFramePaintArea()); 1252 1313 rightClip = clip.clone().intersectWith(getRightFramePaintArea()); 1253 if (!rightClip.isFullyClipped()) rightClip = new Clip(rightClip.getBounds().translate(-getRightFramePaintArea().getMinX(), 0)); 1314 if (!rightClip.isFullyClipped()) { 1315 rightClip = new Clip(rightClip.getBounds().translate(-getRightFramePaintArea().getMinX(), 0)); 1316 } 1254 1317 } 1255 1318 … … 1287 1350 if (useInvalidation) { 1288 1351 messageBayClip = clip.clone().intersectWith(messageBayPaintArea); 1289 if (!messageBayClip.isFullyClipped()) messageBayClip = new Clip(messageBayClip.getBounds().translate(0, -messageBayPaintArea.getMinY())); 1352 if (!messageBayClip.isFullyClipped()) { 1353 messageBayClip = new Clip(messageBayClip.getBounds().translate(0, -messageBayPaintArea.getMinY())); 1354 } 1290 1355 } 1291 1356 … … 1305 1370 1306 1371 // Paint any popups 1307 if (PopupManager.getInstance() != null) PopupManager.getInstance().paint(); 1372 if (PopupManager.getInstance() != null) { 1373 PopupManager.getInstance().paint(); 1374 } 1308 1375 1309 1376 g.popDrawingSurface(); 1310 //System.err.println("DisplayController refresh. Point.ORIGIN=" + Point.ORIGIN);1311 //System.err.println("DisplayController refresh. Graphic=" + g);1312 1377 g.drawImage(_refreshBuffer, Point.ORIGIN); 1313 1378 return true; … … 1317 1382 private static void paintTwinFrames(Image leftFrameImage, Image rightFrameImage) 1318 1383 { 1319 if (leftFrameImage == null && rightFrameImage == null) return; 1384 if (leftFrameImage == null && rightFrameImage == null) { 1385 return; 1386 } 1320 1387 1321 1388 InOutReference<FrameTransition> leftTransition = new InOutReference<FrameTransition>(getTransition(LEFT)); … … 1332 1399 private static void paintSingleFrame(Image frameImage) 1333 1400 { 1334 if (frameImage == null) return; 1401 if (frameImage == null) { 1402 return; 1403 } 1335 1404 1336 1405 InOutReference<FrameTransition> transition = new InOutReference<FrameTransition>(getTransition(getCurrentSide())); … … 1344 1413 private static void paintFrameIntoArea(Image frameImage, AxisAlignedBoxBounds area, InOutReference<FrameTransition> transition) 1345 1414 { 1346 if (frameImage == null || area == null) return; 1415 if (frameImage == null || area == null) { 1416 return; 1417 } 1347 1418 1348 1419 GraphicsManager g = EcosystemManager.getGraphicsManager(); … … 1350 1421 1351 1422 FrameTransition t = null; 1352 if (transition != null) t = transition.get(); 1423 if (transition != null) { 1424 t = transition.get(); 1425 } 1353 1426 1354 1427 // Attempt to draw the transition if there is one … … 1370 1443 1371 1444 // Discard the transition if drawing failed or it is finished 1372 if (t == null || t.isCompleted()) transition.set(null); 1445 if (t == null || t.isCompleted()) { 1446 transition.set(null); 1447 } 1373 1448 1374 1449 g.popClip(key); … … 1424 1499 } 1425 1500 1501 @Override 1426 1502 public void run() 1427 1503 {
Note:
See TracChangeset
for help on using the changeset viewer.