~ubuntu-branches/ubuntu/vivid/tesseract/vivid

« back to all changes in this revision

Viewing changes to java/com/google/scrollview/ScrollView.java

  • Committer: Package Import Robot
  • Author(s): Jeff Breidenbach
  • Date: 2014-02-03 11:10:20 UTC
  • mfrom: (1.3.1) (19.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20140203111020-igquodd7pjlp3uri
Tags: 3.03.01-1
* New upstream release, includes critical fix to PDF rendering
* Complete leptonlib transition (see bug #735509)
* Promote from experimental to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
import com.google.scrollview.events.SVEvent;
14
14
import com.google.scrollview.ui.SVImageHandler;
15
15
import com.google.scrollview.ui.SVWindow;
 
16
import org.piccolo2d.nodes.PImage;
16
17
 
17
18
import java.io.BufferedReader;
18
19
import java.io.IOException;
23
24
import java.util.ArrayList;
24
25
import java.util.regex.Pattern;
25
26
 
26
 
 
27
27
/**
28
28
 * The ScrollView class is the main class which gets started from the command
29
29
 * line. It sets up LUA and handles the network processing.
115
115
            first = !first;
116
116
          }
117
117
          assert first;
118
 
        } else if (SVImageHandler.getReadImageData() == false) {
119
 
          // If we are currently not transmitting an image, process this
120
 
          // normally.
 
118
        } else {
 
119
          // Process this normally.
121
120
          processInput(inputLine);
122
121
        }
123
 
        // We are still transmitting image data, but there seems to be some
124
 
        // command at the
125
 
        // end of the message attached as well. Thus, we have to split it
126
 
        // accordingly and
127
 
        // first generate the image and afterwards process the remaining
128
 
        // message.
129
 
        else if (inputLine.length() >
130
 
                 SVImageHandler.getMissingRemainingBytes()) {
131
 
          String luaCmd = inputLine.substring(
132
 
              SVImageHandler.getMissingRemainingBytes());
133
 
          String imgData = inputLine.substring(0,
134
 
              SVImageHandler.getMissingRemainingBytes());
135
 
          SVImageHandler.parseData(imgData);
136
 
          processInput(luaCmd);
137
 
        } else { // We are still in the middle of image data and have not
138
 
                 // reached the end yet.
139
 
          SVImageHandler.parseData(inputLine);
140
 
        }
141
122
      }
142
123
    }
143
124
    // Some connection error
228
209
 
229
210
  /** Executes the LUA command parsed as parameter. */
230
211
  private static void processInput(String inputLine) {
 
212
    if (inputLine == null) {
 
213
      return;
 
214
    }
231
215
    // Execute a function encoded as a LUA statement! Yuk!
232
216
    if (inputLine.charAt(0) == 'w') {
233
217
      // This is a method call on a window. Parse it.
298
282
        } else if (func.equals("drawText")) {
299
283
          windows.get(windowID).drawText(intList.get(0), intList.get(1),
300
284
                                         stringList.get(0));
301
 
        } else if (func.equals("openImage")) {
302
 
          windows.get(windowID).openImage(stringList.get(0));
303
 
        } else if (func.equals("drawImage")) {
304
 
          windows.get(windowID).drawImage(stringList.get(0),
305
 
                                          intList.get(0), intList.get(1));
306
285
        } else if (func.equals("addMenuBarItem")) {
307
286
          if (boolList.size() > 0) {
308
287
            windows.get(windowID).addMenuBarItem(stringList.get(0),
337
316
        } else if (func.equals("zoomRectangle")) {
338
317
          windows.get(windowID).zoomRectangle(intList.get(0), intList.get(1),
339
318
                                              intList.get(2), intList.get(3));
340
 
        } else if (func.equals("createImage")) {
341
 
          windows.get(windowID).createImage(stringList.get(0), intList.get(0),
342
 
                                            intList.get(1), intList.get(2));
 
319
        } else if (func.equals("readImage")) {
 
320
          PImage image = SVImageHandler.readImage(intList.get(2), in);
 
321
          windows.get(windowID).drawImage(image, intList.get(0), intList.get(1));
343
322
        } else if (func.equals("drawImage")) {
344
 
          windows.get(windowID).drawImage(stringList.get(0),
345
 
                                          intList.get(0), intList.get(1));
 
323
          PImage image = new PImage(stringList.get(0));
 
324
          windows.get(windowID).drawImage(image, intList.get(0), intList.get(1));
346
325
        } else if (func.equals("destroy")) {
347
326
          windows.get(windowID).destroy();
348
327
        }