Changeset 713
- Timestamp:
- 01/16/14 16:23:39 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/io/WebParser.java
r701 r713 3 3 import java.awt.Color; 4 4 import java.awt.Font; 5 import java.awt.FontMetrics; 5 6 import java.awt.image.BufferedImage; 6 7 import java.io.File; … … 243 244 ); 244 245 245 WebParser.addPageToFrame(doc, null,window, webEngine, frame);246 WebParser.addPageToFrame(doc, window, webEngine, frame); 246 247 247 248 progressBar.set(100); … … 308 309 * @throws IllegalAccessException 309 310 */ 310 private static void addPageToFrame(Node rootElement, Color parentBgColor,Object window, Object webEngine, Frame frame) throws InvocationTargetException, IllegalAccessException,311 private static void addPageToFrame(Node rootElement, Object window, Object webEngine, Frame frame) throws InvocationTargetException, IllegalAccessException, 311 312 IllegalArgumentException { 312 313 313 314 Node currentNode = rootElement; 314 315 Color bgColor = null;316 315 317 316 if (currentNode.getNodeType() == Node.TEXT_NODE || currentNode.getNodeType() == Node.ELEMENT_NODE) { … … 343 342 float height = Float.valueOf(JavaFX.JSObjectGetMember.invoke(bounds, "height").toString()); 344 343 345 // Have to get the bg color even if the element isn't visible, so it can be cascaded down to child elements346 // Always returns in format "rgb(x,x,x)" or "rgba(x,x,x,x)"347 String bgColorString = (String) JavaFX.JSObjectCall.invoke(style, "getPropertyValue", new Object[] { "background-color" });348 349 bgColor = rgbStringToColor(bgColorString);350 351 bgColor = (bgColor != null ? bgColor : parentBgColor);352 353 354 344 // Checking if the element is actually visible on the page 355 345 if (WebParser.elementVisible(x, y, width, height, style)) { … … 365 355 String color = (String) JavaFX.JSObjectCall.invoke(style, "getPropertyValue", new Object[] { "color" }); 366 356 357 // Always returns in format "rgb(x,x,x)" or "rgba(x,x,x,x)" 358 String bgColorString = (String) JavaFX.JSObjectCall.invoke(style, "getPropertyValue", new Object[] { "background-color" }); 359 367 360 String align = (String) JavaFX.JSObjectCall.invoke(style, "getPropertyValue", new Object[] { "text-align" }); 368 361 … … 468 461 } 469 462 470 t = frame.addText(Math.round(x), Math.round(y), textContent, null); 463 // Adding the text to the frame. Expeditee text seems to be positioned relative to the baseline of the first line, so 464 // the font size has to be added to the y-position 465 t = frame.addText(Math.round(x), Math.round(y + fontSizeFloat), textContent, null); 471 466 472 467 t.setColor(rgbStringToColor(color)); 473 t.setBackgroundColor( bgColor);468 t.setBackgroundColor(rgbStringToColor(bgColorString)); 474 469 t.setFont(font); 475 470 t.setSize(fontSizeFloat); … … 503 498 } else if (currentNode.getNodeType() == Node.ELEMENT_NODE) { 504 499 500 // Always returns in format "rgb(x,x,x)" or "rgba(x,x,x,x)" 501 String bgColorString = (String) JavaFX.JSObjectCall.invoke(style, "getPropertyValue", new Object[] { "background-color" }); 502 503 Color bgColor = rgbStringToColor(bgColorString); 504 505 // If the element has a background color then add it (to Expeditee) as a rectangle with that background color 506 if (bgColor != null) { 507 System.out.println("bg"); 508 frame.addRectangle(Math.round(x), Math.round(y), Math.round(width), Math.round(height), 0, null, bgColor); 509 } 510 505 511 // background image, returns in format "url(protocol://absolute/path/to/img.extension)" for images, 506 512 // may also return gradients, data, etc. (not handled yet). Only need to add bg image on … … 511 517 512 518 if (bgImage.startsWith("url(")) { 513 514 519 bgImage = bgImage.substring(4, bgImage.length() - 1); 515 520 … … 599 604 600 605 while (childNode != null) { 601 addPageToFrame(childNode, bgColor,window, webEngine, frame);606 addPageToFrame(childNode, window, webEngine, frame); 602 607 childNode = childNode.getNextSibling(); 603 608 }
Note:
See TracChangeset
for help on using the changeset viewer.