Download Jar. Uses 4489K of libraries. Click here for Pure Java version (12617L/91K).
!7 concept Drawing { S globalID = aGlobalID(); S name; S calStructure; } static new CirclesAndLines cal; static Canvas canvas; static S name; p { db(); substance(); swing { canvas = cal.show(800, 600); setCAL(cal); updateDrawingsMenu(); addToWindow(canvas, withMargin(jcenteredline( jbutton("New Circle...", f newCircle), jbutton("Save drawing", f saveDrawing), jbutton("PUBLISH drawing to server", f publish))); addToWindow(canvas, withMargin(jcenteredlabel("Create connections by dragging between circles with right mouse button"))); addDrawingsList(); centerFrame(canvas); hideConsole(); } } svoid newCircle { final JTextField text = jtextfield(); showFormTitled("New Circle", "Text", text, r-thread { loading { cal.circle_autoVis(getTextTrim(text), random(0.2, 0.8), random(0.2, 0.8)); canvas.update(); }}); } static Drawing saveDrawing() { if (empty(name)) { final JTextField tfName = jtextfield(); showFormTitled("Name drawing", "Name", tfName, r { name = getTextTrim(tfName); saveDrawing(); }); null; } S s = cal_structure(cal); Drawing d = cnew(Drawing, calStructure := s, +name); //infoBox("Drawing saved. ID: " + d.id + ", " + lUtf8(quote(s)) + " bytes"); updateDrawingsMenu(); ret d; } svoid newDrawing { setCAL(new CirclesAndLines); name = ""; } svoid updateDrawingsMenu { L params = ll("New drawing", r { newDrawing() }); for (final Drawing d : reversed(list(Drawing))) addAll(params, "Load " + (nempty(d.name) ? quote(d.name) : str(d.id)) + " (made " + renderDate(d.created) + ")", r { loadDrawing(d) }); addMenu(canvas, "Drawings", toObjectArray(params)); } static L<S> makeDrawingsList() { new L<S> l; for (final Drawing d : reversed(list(Drawing))) l.add( "[" + d.id + "] " + (nempty(d.name) ? quote(d.name) + " " : "") /*+ " (" + renderDate(d.created) + ")"*/); ret l; } svoid addDrawingsList { final JList list = jlist(); onDoubleClick(list, voidfunc(S s) { loadDrawing(getConcept(Drawing, parseFirstLong(s))) }); addToWindowSplitRight_aggressive(canvas, list, 0.7f); awtCalcOnConceptsChange(list, r { fillListWithStrings(list, makeDrawingsList()) }); } svoid setCAL(CirclesAndLines cal) { main.cal = cal; Canvas c = canvas; canvas = cal.makeCanvas(); awtReplaceComponent(c, canvas); new CirclesRelater(canvas, cal); } svoid loadDrawing(Drawing d) { CirclesAndLines cal = cast unstructure(d.calStructure); cal_setAutoVis(cal); setCAL(cal); } svoid publish { fS globalID = aGlobalID(); final JTextField tfName = jtextfield(name); showFormTitled("Publish drawing to server?", "Global ID" := globalID, "Name" := tfName, r-thread { loading { name = getTextTrim(tfName); Drawing d = saveDrawing(); cset(d, +globalID, +name); S fullName = "Drawing " + globalID + " " + renderDate(now()) + " - " + or2(name, "Untitled"); S url = uploadToImageServer(canvas.getImage(), fullName); infoBox("Image uploaded to server! " + url); S id = createSuperHighSnippet(structure(d), fullName, 56 /*SN_AI_DRAWING*/, null, null); infoBox("Drawing uploaded. " + fsI(id)); }}); }
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): cfunsshuasjs, meaugxdlecrj, mqqgnosmbjvj, onxytkatvevr, tvejysmllsmz, wtqryiryparv, xinetxnxrdbb
No comments. add comment
Snippet ID: | #1007609 |
Snippet name: | Circles Editor [WORKS basically] |
Eternal ID of this version: | #1007609/48 |
Text MD5: | b0f00d1a7c300483c2c55343eacd85cd |
Transpilation MD5: | 6d36db36b729bc9e120c084df94aa86b |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | Yes |
Created/modified: | 2017-08-28 14:39:43 |
Source code size: | 3389 bytes / 118 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 793 / 3315 |
Version history: | 47 change(s) |
Referenced in: | [show references] |