lib/shoes/swt/image.rb in shoes-swt-4.0.0.pre2 vs lib/shoes/swt/image.rb in shoes-swt-4.0.0.pre3
- old
+ new
@@ -9,12 +9,10 @@
include Common::PainterUpdatesPosition
include Common::Visibility
include Common::Remove
include ::Shoes::BackendDimensionsDelegations
- BINARY_ENCODING = Encoding.find('binary')
-
attr_reader :parent, :real, :dsl, :painter
def initialize(dsl, parent)
@dsl = dsl
@parent = parent
@@ -27,10 +25,11 @@
def update_image
load_image(@dsl.file_path)
end
private
+
def load_image(name_or_data)
if url?(name_or_data)
save_width_and_height
display_temporary_download_image
download_and_display_real_image(name_or_data)
@@ -38,11 +37,11 @@
display_image(name_or_data)
end
end
def url?(name_or_data)
- name_or_data =~ /^(http|https):\/\//
+ @dsl.url?(name_or_data)
end
def save_width_and_height
@saved_width = dsl.element_width
@saved_height = dsl.element_height
@@ -100,11 +99,11 @@
end
create_image(data)
end
def raw_image_data?(name_or_data)
- name_or_data.encoding == BINARY_ENCODING
+ @dsl.raw_image_data?(name_or_data)
end
def load_raw_image_data(name_or_data)
stream = ByteArrayInputStream.new(name_or_data.to_java_bytes)
begin
@@ -120,9 +119,8 @@
graphics_context = event.gc
graphics_context.drawImage @real, 0, 0, @full_width, @full_height, dsl.element_left, dsl.element_top, dsl.element_width, dsl.element_height unless @dsl.hidden
end
app.add_paint_listener(@painter)
end
-
end
end
end