Ignore:
Timestamp:
05/10/18 16:04:51 (6 years ago)
Author:
davidb
Message:

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/MagneticConstraint/Utilities/TextLogic.java

    r963 r1102  
    11package org.expeditee.items.MagneticConstraint.Utilities;
    22
    3 import org.expeditee.gui.Browser;
    4 import org.expeditee.gui.DisplayIO;
     3import org.expeditee.gio.EcosystemManager;
     4import org.expeditee.gui.DisplayController;
    55import org.expeditee.items.Text;
    66
     
    99        public static boolean XIsTowardsRight(final int x, final Text text) {
    1010                if(text.getPixelBoundsUnion() == null) return false;
    11                 final double distanceThroughText = x - text.getPixelBoundsUnion().getX();
     11                final double distanceThroughText = x - text.getPixelBoundsUnion().getMinX();
    1212                return /*text.getText().length() == 1 ||*/ distanceThroughText > (text.getPixelBoundsUnion().getWidth() / 2);
    1313        }
     
    1515        public static boolean XIsTowardsLeft(final Text text, final int x) {
    1616                if(text.getPixelBoundsUnion() == null) return false;
    17                 final double distanceThroughText = x - text.getPixelBoundsUnion().getX();
     17                final double distanceThroughText = x - text.getPixelBoundsUnion().getMinX();
    1818                return distanceThroughText < (text.getPixelBoundsUnion().getWidth() / 2);
    1919        }
     
    2121        public static boolean XIsBeforeCharacters(final Text text, final int x) {
    2222                try {
    23                         final int firstLetterWidth = Browser._theBrowser.getFontMetrics(Browser._theBrowser.getFont()).stringWidth(text.getText().substring(0, 1));
    24                         final double distanceThroughText = x - text.getPixelBoundsUnion().getX();
     23                        final int firstLetterWidth = EcosystemManager.getTextLayoutManager().getStringWidth(null, text.getText().substring(0, 1));
     24                        final double distanceThroughText = x - text.getPixelBoundsUnion().getMinX();
    2525                        return firstLetterWidth > distanceThroughText;
    2626                } catch (NullPointerException e) {
     
    3333        public static boolean XIsAfterCharacters(final Text text, final int x) {
    3434                try {
    35                         final double distanceThroughText = x - text.getPixelBoundsUnion().getX();
     35                        final double distanceThroughText = x - text.getPixelBoundsUnion().getMinX();
    3636                        return distanceThroughText > text.getPixelBoundsUnion().getWidth();
    3737                } catch (NullPointerException e) {
     
    4141       
    4242        public static int GetInsertionIndexSelected(final Text text) {
    43                 return text.getCharPosition(0, DisplayIO.getMouseX()).getInsertionIndex();
     43                return text.getCharPosition(0, DisplayController.getMouseX()).getInsertionIndex();
    4444        }
    4545}
Note: See TracChangeset for help on using the changeset viewer.