Changeset 1525


Ignore:
Timestamp:
04/21/20 16:21:20 (4 years ago)
Author:
bnemhaus
Message:

org.expeditee.core.Anchoring -> Rename some parameters to have better names.
org.expeditee.items.widgets.Widget -> Widgets now anchor from two points, their top left corner and their bottom right corner. This allows a widget to have anchoring both left and right (or top and bottom). The left (or top) anchor applies to one of the anchor points. The right (or bottom) to the other.

Location:
trunk/src/org/expeditee
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/core/Anchoring.java

    r1513 r1525  
    131131        }
    132132                       
    133         private void setXAnchor(Integer offset, VerticalDirection left) {
     133        private void setXAnchor(Integer offset, VerticalDirection vertical_direction) {
    134134                _xAnchor = offset;
    135                 verticalDirection = left;
     135                verticalDirection = vertical_direction;
    136136        }
    137137
    138         private void setYAnchor(Integer offset, HorizontalDirection top) {
     138        private void setYAnchor(Integer offset, HorizontalDirection horizontal_direction) {
    139139                _yAnchor = offset;
    140                 horizonalDirection = top;
     140                horizonalDirection = horizontal_direction;
    141141        }
    142142       
  • trunk/src/org/expeditee/items/widgets/Widget.java

    r1511 r1525  
    7171        public final static float DEFAULT_MINIMUM_BORDER_THICKNESS = 1.0f;
    7272       
     73        // @formatter:off
    7374        /* GUIDE:
    7475         * d1--l1---d2
     
    7879         * d4---l3--d3
    7980         */
    80 
    81         /** The top-left corner of the widget. */
     81        // @formatter:on
     82
     83        /** The top-left corner of the widget. */
    8284        private WidgetCorner _d1;
    8385        /** The top-right corner of the widget. */
     
    8587        /** The bottom-right corner of the widget. */
    8688        private WidgetCorner _d3;
    87         /** The bottom-left corner of the widget. */
     89        ///** The bottom-left corner of the widget. */
    8890        private WidgetCorner _d4;
     91       
     92        /** The Anchoring for the top-left corner of the widget */
     93        private Anchoring _d1Anchoring = new Anchoring();
     94        /** The Anchoring for the bottom-right corner of the widget */
     95        private Anchoring _d3Anchoring = new Anchoring();
    8996
    9097        /** The top edge of the widget. */
     
    112119        /** The Expeditee item that is used for saving widget state. */
    113120        protected Text _textRepresentation;
    114 
    115         /** The anchoring of the widget. */
    116         protected Anchoring _anchoring = new Anchoring();
    117121
    118122        /**
     
    735739                sb.append(getClass().getName());
    736740
    737                 if (_anchoring.getLeftAnchor() != null) {
    738                     sb.append(" --anchorLeft " + Math.round(_anchoring.getLeftAnchor()));
    739                 }
    740                 if (_anchoring.getRightAnchor() != null) {
    741                     sb.append(" --anchorRight " + Math.round(_anchoring.getRightAnchor()));
    742                 }
    743 
    744                 if (_anchoring.getTopAnchor() != null) {
    745                     sb.append(" --anchorTop " + Math.round(_anchoring.getTopAnchor()));
    746                 }
    747 
    748                 if (_anchoring.getBottomAnchor() != null) {
    749                     sb.append(" --anchorBottom " + Math.round(_anchoring.getBottomAnchor()));
     741                if (_d1Anchoring.getLeftAnchor() != null) {
     742                    sb.append(" --anchorLeft " + Math.round(_d1Anchoring.getLeftAnchor()));
     743                }
     744                if (_d3Anchoring.getRightAnchor() != null) {
     745                    sb.append(" --anchorRight " + Math.round(_d3Anchoring.getRightAnchor()));
     746                }
     747
     748                if (_d1Anchoring.getTopAnchor() != null) {
     749                    sb.append(" --anchorTop " + Math.round(_d1Anchoring.getTopAnchor()));
     750                }
     751
     752                if (_d3Anchoring.getBottomAnchor() != null) {
     753                    sb.append(" --anchorBottom " + Math.round(_d3Anchoring.getBottomAnchor()));
    750754                }
    751755
     
    18071811        public void setAnchorLeft(final Integer anchor)
    18081812        {
    1809                 _anchoring.setLeftAnchor(anchor);
     1813                _d1Anchoring.setLeftAnchor(anchor);
    18101814                // Anchor left-edge corners (dots) as well
    18111815                _d1.setAnchorCornerX(anchor,null);
     
    18221826
    18231827        public void setAnchorRight(final Integer anchor) {
    1824                 _anchoring.setRightAnchor(anchor);
     1828                _d3Anchoring.setRightAnchor(anchor);
    18251829                // Anchor right-edge corners (dots) as well
    18261830                _d2.setAnchorCornerX(null,anchor); // right
     
    18321836                }
    18331837               
    1834                 if (_anchoring.getLeftAnchor() == null) {
     1838                if (_d1Anchoring.getLeftAnchor() == null) {
    18351839                        // Prefer having the X-rayable item at anchorLeft position (if defined) over moving to anchorRight
    18361840                        getCurrentRepresentation().setAnchorRight(anchor);
     
    18391843       
    18401844        public void setAnchorTop(final Integer anchor) {
    1841                 _anchoring.setTopAnchor(anchor);
     1845                _d1Anchoring.setTopAnchor(anchor);
    18421846                // Anchor top-edge corners (dots) as well
    18431847                _d1.setAnchorCornerY(anchor,null);
     
    18541858
    18551859        public void setAnchorBottom(final Integer anchor) {
    1856                 _anchoring.setBottomAnchor(anchor);
     1860                _d3Anchoring.setBottomAnchor(anchor);
    18571861                // Anchor bottom-edge corners (dots) as well
    18581862                _d3.setAnchorCornerY(null,anchor);
     
    18641868                }
    18651869               
    1866                 if (_anchoring.getTopAnchor() == null) {
     1870                if (_d1Anchoring.getTopAnchor() == null) {
    18671871                    // Prefer having the X-rayable item at anchorTop position (if defined) over moving to anchorBottom
    18681872                        getCurrentRepresentation().setAnchorBottom(anchor);
     
    18761880
    18771881        public boolean isAnchoredX() {
    1878                 return _anchoring.isXAnchored();
     1882                return _d1Anchoring.isXAnchored() || _d3Anchoring.isXAnchored();
    18791883        }
    18801884
    18811885        public boolean isAnchoredY() {
    1882                 return _anchoring.isYAnchored();
     1886                return _d1Anchoring.isYAnchored() || _d3Anchoring.isYAnchored();
    18831887        }
    18841888       
Note: See TracChangeset for help on using the changeset viewer.