1 /* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.glass.ui.monocle; 27 28 public class TouchFilterShim implements TouchFilter { 29 30 public boolean filter(TouchState ts) { 31 throw new RuntimeException("not implemented"); 32 } 33 34 public boolean flush(TouchState ts) { 35 throw new RuntimeException("not implemented"); 36 } 37 38 public int getPriority() { 39 throw new RuntimeException("not implemented"); 40 } 41 42 public static class TranslateFilter extends TouchFilterShim { 43 @Override 44 public boolean filter(TouchState state) { 45 for (int i = 0; i < state.getPointCount(); i++) { 46 state.getPoint(i).x += 8; 47 state.getPoint(i).y -= 5; 48 } 49 return false; 50 } 51 52 @Override 53 public int getPriority() { 54 return 50; 55 } 56 57 @Override 58 public boolean flush(TouchState state) { 59 return false; 60 } 61 } 62 63 public static class OverrideIDFilter extends TouchFilterShim { 64 @Override 65 public boolean filter(TouchState state) { 66 for (int i = 0; i < state.getPointCount(); i++) { 67 state.getPoint(i).id = 5; 68 } 69 return false; 70 } 71 72 @Override 73 public int getPriority() { 74 return -50; 75 } 76 77 @Override 78 public boolean flush(TouchState state) { 79 return false; 80 } 81 } 82 83 public static class NoMultiplesOfTenOnXFilter extends TouchFilterShim { 84 @Override 85 public boolean filter(TouchState state) { 86 for (int i = 0; i < state.getPointCount(); i++) { 87 if (state.getPoint(i).x % 10 == 0) { 88 return true; 89 } 90 } 91 return false; 92 } 93 94 @Override 95 public int getPriority() { 96 return 60; 97 } 98 99 @Override 100 public boolean flush(TouchState state) { 101 return false; 102 } 103 } 104 105 public static class LoggingFilter extends TouchFilterShim { 106 @Override 107 public boolean filter(TouchState state) { 108 for (int i = 0; i < state.getPointCount(); i++) { 109 TestLog.format("Touch point id=%d at %d,%d", 110 state.getPoint(i).id, 111 state.getPoint(i).x, 112 state.getPoint(i).y); 113 } 114 return false; 115 } 116 117 @Override 118 public int getPriority() { 119 return -100; 120 } 121 122 @Override 123 public boolean flush(TouchState state) { 124 return false; 125 } 126 } 127 128 public static class FlushingFilter extends TouchFilterShim { 129 int i = 3; 130 @Override 131 public boolean filter(TouchState state) { 132 return false; 133 } 134 135 @Override 136 public int getPriority() { 137 return 90; 138 } 139 140 @Override 141 public boolean flush(TouchState state) { 142 if (i > 0) { 143 i --; 144 state.clear(); 145 TouchState.Point p = state.addPoint(null); 146 p.x = 205 + i * 100; 147 p.y = 100; 148 p.id = -1; 149 return true; 150 } else { 151 return false; 152 } 153 } 154 } 155 156 }