Ignore:
Timestamp:
09/28/18 09:33:46 (6 years ago)
Author:
bln4
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/DisplayController.java

    r1157 r1171  
    170170        private static void fireFrameChanged()
    171171        {
    172                 for (DisplayObserver observer : _displayObservers) observer.frameChanged();
     172                for (DisplayObserver observer : _displayObservers) {
     173                        observer.frameChanged();
     174                }
    173175        }
    174176
     
    187189        public static void addDisplayObserver(DisplayObserver observer)
    188190        {
    189                 if (observer == null) throw new NullPointerException("observer");
     191                if (observer == null) {
     192                        throw new NullPointerException("observer");
     193                }
    190194               
    191195                _displayObservers.add(observer);
     
    205209        public static void removeDisplayObserver(DisplayObserver observer)
    206210        {
    207                 if (observer == null) throw new NullPointerException("observer");
     211                if (observer == null) {
     212                        throw new NullPointerException("observer");
     213                }
    208214               
    209215                _displayObservers.remove(observer);
     
    231237                int size = Math.round(text.getSize());
    232238               
    233                 if (allowClearSelection && !isShiftDown && text.hasSelection()) text.clearSelection();
     239                if (allowClearSelection && !isShiftDown && text.hasSelection()) {
     240                        text.clearSelection();
     241                }
    234242
    235243                Point newMouse = text.moveCursor(cursorMovement, DisplayController.getFloatMouseX(), EcosystemManager.getInputManager().getCursorPosition().getY(), isShiftDown, isCtrlDown);
     
    257265
    258266                if (!newSize && _cursorType == Item.TEXT_CURSOR) {
    259                         if (cursorMovement != 0)
     267                        if (cursorMovement != 0) {
    260268                                DisplayController.setCursorPosition(newMouse, false);
     269                        }
    261270                        return;
    262271                }
     
    330339        {
    331340                // Avoid flicker when not changing
    332                 if (type == _cursorType) return;
     341                if (type == _cursorType) {
     342                        return;
     343                }
    333344
    334345                _cursorType = type;
     
    463474
    464475                // 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                }
    466479
    467480                // if the stack is empty, return null
     
    472485        public static void setTransition(Frame frame, FrameTransition transition)
    473486        {
    474                 if (frame == null) return;
     487                if (frame == null) {
     488                        return;
     489                }
    475490                TwinFramesSide side = getSideFrameIsOn(frame);
    476491                setTransition(side, transition);
     
    480495        private static void setTransition(TwinFramesSide side, FrameTransition transition)
    481496        {
    482                 if (side == null) return;
     497                if (side == null) {
     498                        return;
     499                }
    483500               
    484501                _transitions[side.ordinal()] = transition;
     
    488505        private static FrameTransition getTransition(TwinFramesSide side)
    489506        {
    490                 if (side == null) return null;
     507                if (side == null) {
     508                        return null;
     509                }
    491510               
    492511                return _transitions[side.ordinal()];
     
    499518        public static void setCurrentFrame(Frame frame, boolean incrementStats)
    500519        {
    501                 if (frame == null) return;
     520                if (frame == null) {
     521                        return;
     522                }
    502523
    503524                // If one of the sides doesn't have a frame yet, give it this one
     
    520541               
    521542                // Update stats
    522                 if (incrementStats) SessionStats.AccessedFrame();
     543                if (incrementStats) {
     544                        SessionStats.AccessedFrame();
     545                }
    523546
    524547                // Invalidate free items
     
    571594                        // Get all overlayed frames seen by the next frame
    572595                        for (Overlay o : frame.getOverlays()) {
    573                                 if (!nextOnlyOverlays.contains(o.Frame))
     596                                if (!nextOnlyOverlays.contains(o.Frame)) {
    574597                                        nextOnlyOverlays.add(o.Frame);
     598                                }
    575599                        }
    576600
     
    578602                        if (getCurrentFrame() != null) {
    579603                                for (Overlay o : getCurrentFrame().getOverlays()) {
    580                                         if (!currentOnlyOverlays.contains(o.Frame))
     604                                        if (!currentOnlyOverlays.contains(o.Frame)) {
    581605                                                currentOnlyOverlays.add(o.Frame);
     606                                        }
    582607                                }
    583608                        }
     
    605630                                // possible non-shared overlays
    606631                                items = getCurrentFrame().getAllItems();
    607                                 for (Frame f : seen)
     632                                for (Frame f : seen) {
    608633                                        items.removeAll(f.getAllItems());
     634                                }
    609635
    610636                                // Notify items that they are hidden
     
    687713               
    688714                // 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                }
    690718
    691719                // In any other case the left side is the current side
     
    696724        private static TwinFramesSide getOppositeSide()
    697725        {
    698                 if (getCurrentSide() == LEFT) return RIGHT;
     726                if (getCurrentSide() == LEFT) {
     727                        return RIGHT;
     728                }
    699729
    700730                return LEFT;
     
    706736                // Loop through both sides
    707737                for (TwinFramesSide side : TwinFramesSide.values()) {
    708                         if (getFrameOnSide(side) == frame) return side;
     738                        if (getFrameOnSide(side) == frame) {
     739                                return side;
     740                        }
    709741                }
    710742
     
    715747        public static Frame getFrameOnSide(TwinFramesSide side)
    716748        {
    717                 if (side == null) return null;
     749                if (side == null) {
     750                        return null;
     751                }
    718752               
    719753                return _currentFrames[side.ordinal()];
     
    747781        public static Line getTwinFramesSeparatorLine()
    748782        {
    749                 if (!isTwinFramesOn()) return null;
     783                if (!isTwinFramesOn()) {
     784                        return null;
     785                }
    750786               
    751787                int x = getTwinFramesSeparatorX();
     
    760796        {
    761797                // No message bay in audience mode
    762                 if (isAudienceMode()) return null;
     798                if (isAudienceMode()) {
     799                        return null;
     800                }
    763801               
    764802                int separatorThickness = (int) SEPARATOR_STROKE.thickness;
     
    778816        public static float getFloatMouseX()
    779817        {
    780                 return (float) getMouseX();
     818                return getMouseX();
    781819        }
    782820
     
    820858        public static float getFloatMouseY()
    821859        {
    822                 return (float) getMouseY();
     860                return getMouseY();
    823861        }
    824862       
     
    857895
    858896                // 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                }
    860900               
    861901                Frame frame = FrameIO.LoadFrame(removeFromBack());
     
    913953
    914954                // do not get a cached version (in case it is in the other window)
    915                 if (isTwinFramesOn())
     955                if (isTwinFramesOn()) {
    916956                        FrameIO.SuspendCache();
     957                }
    917958                Frame frame = FrameIO.LoadFrame(getBackedUpFrames(side).pop());
    918959                // If the top frame on the backup stack is the current frame go back
     
    9641005               
    9651006                // 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                }
    9681013
    9691014                requestRefresh(false);
     
    9791024        public static void Reload(TwinFramesSide side)
    9801025        {
    981                 if (side == null) return;
     1026                if (side == null) {
     1027                        return;
     1028                }
    9821029
    9831030                FrameIO.SuspendCache();
     
    10291076        private static void setFrameOnSide(Frame frame, TwinFramesSide side)
    10301077        {
    1031                 if (side == null) return;
     1078                if (side == null) {
     1079                        return;
     1080                }
    10321081               
    10331082                _currentFrames[side.ordinal()] = frame;
     
    10371086        private static Stack<String> getVisitedFrames(TwinFramesSide side)
    10381087        {
    1039                 if (side == null) return null;
     1088                if (side == null) {
     1089                        return null;
     1090                }
    10401091               
    10411092                return _visitedFrames[side.ordinal()];
     
    10451096        private static Stack<String> getBackedUpFrames(TwinFramesSide side)
    10461097        {
    1047                 if (side == null) return null;
     1098                if (side == null) {
     1099                        return null;
     1100                }
    10481101               
    10491102                return _backedUpFrames[side.ordinal()];
     
    10871140               
    10881141                // Turn off x-ray mode if it's on
    1089                 if (_xrayMode) ToggleXRayMode();
     1142                if (_xrayMode) {
     1143                        ToggleXRayMode();
     1144                }
    10901145       
    10911146                // Toggle audience mode
     
    11051160        {
    11061161                // Turn off x-ray mode if it is on
    1107                 if (_audienceMode) ToggleAudienceMode();
     1162                if (_audienceMode) {
     1163                        ToggleAudienceMode();
     1164                }
    11081165
    11091166                _xrayMode = !_xrayMode;
     
    11941251        public static void invalidateItem(Item damagedItem, Bounds toRepaint)
    11951252        {
    1196                 if (toRepaint == null) return;
     1253                if (toRepaint == null) {
     1254                        return;
     1255                }
    11971256               
    11981257                // Only add area to repaint if item is visible...
     
    12391298               
    12401299                // No damaged areas
    1241                 if (useInvalidation && clip.isFullyClipped()) return true;
     1300                if (useInvalidation && clip.isFullyClipped()) {
     1301                        return true;
     1302                }
    12421303                               
    12431304                GraphicsManager g = EcosystemManager.getGraphicsManager();
     
    12511312                                leftClip = clip.clone().intersectWith(getLeftFramePaintArea());
    12521313                                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                                }
    12541317                        }
    12551318                       
     
    12871350                        if (useInvalidation) {
    12881351                                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                                }
    12901355                        }
    12911356                       
     
    13051370               
    13061371                // Paint any popups
    1307                 if (PopupManager.getInstance() != null) PopupManager.getInstance().paint();
     1372                if (PopupManager.getInstance() != null) {
     1373                        PopupManager.getInstance().paint();
     1374                }
    13081375               
    13091376                g.popDrawingSurface();
    1310                 //System.err.println("DisplayController refresh.  Point.ORIGIN=" + Point.ORIGIN);
    1311                 //System.err.println("DisplayController refresh.  Graphic=" + g);
    13121377                g.drawImage(_refreshBuffer, Point.ORIGIN);
    13131378                return true;
     
    13171382        private static void paintTwinFrames(Image leftFrameImage, Image rightFrameImage)
    13181383        {
    1319                 if (leftFrameImage == null && rightFrameImage == null) return;
     1384                if (leftFrameImage == null && rightFrameImage == null) {
     1385                        return;
     1386                }
    13201387               
    13211388                InOutReference<FrameTransition> leftTransition = new InOutReference<FrameTransition>(getTransition(LEFT));
     
    13321399        private static void paintSingleFrame(Image frameImage)
    13331400        {
    1334                 if (frameImage == null) return;
     1401                if (frameImage == null) {
     1402                        return;
     1403                }
    13351404
    13361405                InOutReference<FrameTransition> transition = new InOutReference<FrameTransition>(getTransition(getCurrentSide()));
     
    13441413        private static void paintFrameIntoArea(Image frameImage, AxisAlignedBoxBounds area, InOutReference<FrameTransition> transition)
    13451414        {
    1346                 if (frameImage == null || area == null) return;
     1415                if (frameImage == null || area == null) {
     1416                        return;
     1417                }
    13471418               
    13481419                GraphicsManager g = EcosystemManager.getGraphicsManager();
     
    13501421               
    13511422                FrameTransition t = null;
    1352                 if (transition != null) t = transition.get();
     1423                if (transition != null) {
     1424                        t = transition.get();
     1425                }
    13531426               
    13541427                // Attempt to draw the transition if there is one
     
    13701443               
    13711444                // 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                }
    13731448               
    13741449                g.popClip(key);
     
    14241499                }
    14251500
     1501                @Override
    14261502                public void run()
    14271503                {
Note: See TracChangeset for help on using the changeset viewer.