Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## This is a prototype Shoes app to make Mapnik stylesheet editing a little bit easier.
- ## More of a proof of concept -- manysuchthings are hardcoded (image sizes, file names)
- #
- class DebugShoes < Shoes # Shoes got you down? DebugShoes won't fail silently on ya...
- def self.app(*args, &blk)
- super(*args) do
- begin
- self.instance_eval(&blk)
- rescue => e
- error(e) # log the error and inform the user!
- @err_bar = flow :width => 1.0, :height => 32, :top => self.height-32, :left => 0 do
- background lightgrey
- stack :width => self.width-100
- stack :width => 20, :margin => 4 do image "#{DIR}/static/icon-error.png" end;
- stack :width => 80 do para(link("#{Shoes.log.length} Errors!", :stroke => red) { Shoes.show_log }) end;
- end
- end
- end
- end
- end
- class Image
- def reload
- self.path = "./" + path # reload hack, cache begone!
- self.hide.show
- end
- end
- DebugShoes.app :width => 1360, :height => 720, :title => 'MappinPrototype' do
- STYLE_XML = 'style.xml'
- IMAGE_PNG = 'cali.png'
- MAP_APP = './cali ~/src/mapnik'
- animate(2) do
- if @render then
- @render = false
- `#{MAP_APP}` # shell out to run Map app
- @bg.reload
- end
- end
- background black
- flow do
- stack :width=>820, :margin=>15 do
- @bg = image IMAGE_PNG, :width=>800, :height=>680
- end
- stack :width => 530, :margin=>15 do
- background lightgrey, :curve => 12
- para "Layers"
- @e = edit_box "Would that I...", :width => 500, :height => 620
- @e.text = IO.read(STYLE_XML)
- button "Render!", :margin=>5 do
- warn "Rendering..."
- open(STYLE_XML, 'w') { |f| f.puts @e.text }
- @bg.blur 10
- @bg.hide.show # reload
- @render = true # defer rendering so that blur effect becomes visible
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment