< prev index next >

modules/graphics/src/test/java/test/com/sun/javafx/pgstub/StubTextLayout.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 128,144 **** public Shape getShape(int type, TextSpan filter) { return new Path2D(); } @Override ! public HitInfo getHitInfo(float x, float y) { // TODO this probably needs to be entirely rewritten... if (text == null) { ! final HitInfo hit = new HitInfo(); ! hit.setCharIndex(0); ! hit.setLeading(true); ! return hit; } final double fontSize = (font == null ? 0 : ((Font)font).getSize()); final String[] lines = text.split("\n"); int lineIndex = Math.min(lines.length - 1, (int) (y / fontSize)); --- 128,141 ---- public Shape getShape(int type, TextSpan filter) { return new Path2D(); } @Override ! public Hit getHitInfo(float x, float y) { // TODO this probably needs to be entirely rewritten... if (text == null) { ! return new Hit(0, -1, true); } final double fontSize = (font == null ? 0 : ((Font)font).getSize()); final String[] lines = text.split("\n"); int lineIndex = Math.min(lines.length - 1, (int) (y / fontSize));
*** 155,167 **** int charPos = (int) (x / lines[lineIndex].length()); if (charPos + offset > text.length()) { throw new IllegalStateException("Asked for hit info out of x range"); } ! final HitInfo hit = new HitInfo(); ! hit.setCharIndex(offset + charPos); ! return hit; } @Override public PathElement[] getCaretShape(int offset, boolean isLeading, float x, float y) { --- 152,162 ---- int charPos = (int) (x / lines[lineIndex].length()); if (charPos + offset > text.length()) { throw new IllegalStateException("Asked for hit info out of x range"); } ! return new Hit(offset + charPos, -1, true); } @Override public PathElement[] getCaretShape(int offset, boolean isLeading, float x, float y) {
< prev index next >