Top Banner

of 110

Notes on multiple Language

Oct 07, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

GWTUI ElementsLayoutsBehaviourWidgetsPanelsValidatorssetLeftWidgetsetRightWidgetEnum.valueOfsetWordWrapTimer.schedulescheduleRepeatingHorizontalPanelVerticalPanelHorizontalSplitPanelFlexTableTabPanelonModuleLoadaddStyleNamesetVisibleLinessetCharacterWidthsetPixelSizesetSizesetVisibleItemCountaddItemsetItemSelectedHasAlignment.ALIGN_MIDDLEClickHandlerKeyPressHandlerKeyCodes.KEY_ENTERgetCharCodeKeyPressEventDocPanelsetCellWidthsetCellHeightsetBorderWidthserVerticalAlignmentsetHorizontalAlignmentComposite initWidgetPopupPanelsetPopupPositionAndShowPositionCallbacksetPopupPositionWindow.getClientWidthHtmlTableGridFlexTablegetCellFormattergetColumnFormattergetRowFormattergetRowCountremoveRowaddStyleNameaddStyleDependentNameTreeTreeItemOnTreeItemSelectedaddTreeListeneronTreeItemStateChangedPropertyResourceBundleImageBundleAbstractImagePrototype@ResourceRequestFactoryRequestContextEntityProxy

CSS.hsplitterselectorattributeinside head elemet

MiscRandom.nextDoubleNumberFormat.getFormatDateTimeFormat.getMediumDateTimeFormat

AJAXXmlHttpRequestGWTTestCaseAsyncCallbackonSuccessonFailureBlurHandleronBlurBlurEventGWT.getModuleBaseURL@RemoteServicesRelativePathimplement IsSerializable interfacexxx_CustomFieldSerializer serialize,deserialize, instantiategetThreadLocalRequestSerializationExceptionSerializationStreamReaderSerializationStreamWriterHandlers preferred to Listeners in GWTTabPanelGridUiBinder@UiField u:fieldu:styleComposite@UiTemplate .ui.xml@UiHandler@UiField (provided=true)@UiFactory MyWidgetClass fac(args) { return new MyWidgetClass(args);}@UiConstructor and give 'init' attributeHTMLPanelHasHTML InterfaceWidget Objects Vs DOM elementsSpanElementsetInnerTextinterface Binder extends UiBinder {}GWT.create(Binder.class)binder.createAndBindUi(this)initWidget(ViewThis)xmlns:h='urn:import:com.fkereki.mvpproject.client'>

Guiceextend AbstractModulemap types to their implementationconfigure method of Modulebind(interface.class).to(implementation.class)GIN module for GWTinherits InjectGinjectorAbstractGinModuleGuice @InjectGuice.createInjector (module)injectoor.getInstance

DataStoreJDO, JPA @EntityEntity @Size(min = 3, max = 30)@NotNull@JoinColumn@Id@Column@GeneratedValue (strategy=GenerationType.IDENTITY)@Version@Transientextend EntityProxy@ProxyForName@ProxyFor(Entoty.class)extend ValueProxy@Embedded@ExtraTypesinterface MyRequestFactory extends RequestFactory@Service (service implementation class)@ServiceNameinterface ServiceRequest extends RequestContextRequestInstanceRequestRequest.fire()History.newItem(token)History.addValueChangeHandler

EntityManager.createQuery().getResultListEMF.get().createEntityManagerem.persist(this)em.remove()extend Locator createServiceLocatorMyServiceLocator implements ServiceLocator getInstance newInstanceAnnotate the Service Intarface with ServiceImplementation and ServiceLocator@Service(value= , locator= )RequestFactory ans ServiceLocator caches service instances. So should be threadsafeActivity - restore state, setup, and load UI.Activity Manager starts ans stops ActivitiesPlaceTokenizerPlaceHistoryHandlerextend IsWidgetimplementations extend CompositeDOM.createSpanviewpanel.getElement().appendChild()initWidgetPresenter interface and setPresenterClientFactoryActivities and Placesnew PlaceController(eventBus)Activities implement Presenter interface and extend AbstractActivityActivity::start(Widget, EventBus)clientFactory.getPlaceController.goTo(place)Activities are disposableActivities are associated with Placesupdate the URL in PLaceHistoryHandlerPlaceTokenizer as a static class inside PlaceBasicPlacePlaceHistoryMapper@WithTokenizersPlaceHistoryMapperGenerator

ActivityMapper interface maps Activities with Placesif(place instanceOf SomePlace) new SomeActivity(someplace)clientFactory provides ActivitiesclientFactory.getEventBusclientFactory.getPlaceControllerclientFactory is created with GWT.createActivityManager(ActivityMapper, clientFactory)AppPlaceHistoryMapper is also created with GWT.createPlaceHistoryHandler(placeHistoryMapper)historyHandler.register(placecontroller, eventBus, defaultPlace)historyHandler.handleCurrentHistoryActivityManager for one Container Widget

UIBinder Hello, .

Inside Corresponding Java View Classinterface MyUiBinder extends UiBinder {} private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);@UiField nameSpan public HelloWorld() { setElement(uiBinder.createAndBindUi(this)); }

Direct DOM manipulationDocument.get().getBody().appendChild(helloWorld.getElement());UiBinder instances are factories that generate a UI structuresUiBinder U is the root element, O is the owner.

ROO

LISPlistpfirstrestsetfsetqdefunappendlengthnumberpatomcarcadrifcond

predicateAtomListNILTNULL for checking empty listNOT for checking other false'and' and 'or' are functions but not predicates as they return valuesequaleqeql=defstructstructures have names and slotsmake-structurename(employee-age employee1)(make-employee :slotname val)typepeach instance of a structure has a typeprintprin1 - no newlineprinc - no quotesTerpri - newlineformatcontrol sequence begins with ~~% newline~s~T tabspacing~~*terminal-io*readread-lineread-char

'labels' is like 'let' for functions(proclaim '(optimize speed))(proclaim '(inline fun))compiled-function-p(compile 'foo)(complie nil '(lambda ))(compile-file)(trace some_fun) to trace the functionlocal variables with 'let''let' does all the assignments in parallel'let*' for sequential assignment(lambda )(apply )FUNCALLapply is a function not a macroMAPCAR applies a function repeatedly to each element of a listBackQuote and Commaswith-open-file macromacroexpandmacroexpand-1symbol-valuesymbol-function#'rotatefnreversenconc*!equivs*loopdodo*dotimesdolisttail recursion - result obtainedfrom last call(time expr)return-from blockname returnvalueassocsetf and getsymbol-plistmake-arrayaref and setf:initial-contentsMacro Expansion happens before any arguments are evaluatedMacro creates another lisp object for evaluation'setf' is macroMacros do not evaluate all their argumentschoosefailfind-if*paths*remove-if-not*package*usercommon-lisp-user(package-name *package*)(symbol-package 'foo)(in-package 'mine :use 'common-lisp)(export 'bar)(import 'common-lisp-user:bar)(use-package 'common-lisp-user)in-packagedefpackage:nicknames:export:use

PyQtself.sendershort circuit signalswithout signal signaruresa signal can be connected to a signalQSignalMapperEventHandling two ways1)High level signal and slot 2)Low level eventskeyPressEventmousePressEventmouseReleaseEventresizeEventpaintEventQevent.ToolBarChangeBefore any specific event handler is called event() routine is calledinstallEventFilter on QObjectmultiple event filters to disable or modify the event before it reaches its targetnotify is called before event filters or event handlers. so subclass QApplication and then reimplement notifytextEditedreturnPressedvalueChangedcurrentIndexChanged(int)toggled(bool)setVisible(bool)aboutToShow()destroyed(QObject *)toggled(bool)QDialogButoonBoxQPushButton can be made toggle button by setCheckable

Qpainter.TextAntialiasingsetRenderHintself.update() to schedule a paint eventQwidget.keyPressEvent(self,event)menu.exec(event.globalPOs())globalPos = self.mapToGlobal(event.pos())Qtimer.singleShotQT.Key_HomeQt.Key_Endevent.size()event.key()event.modifiersQt.ControlModifierlambda functions used in SIGNALare nnot garbage collectedsize policystretch factorssetStretchFactor(index,factor)subclass and implementsizeHintminimumSizeHint to retunr the size we wantQTabWidgetcurrentIndexsetCurrentTabTextaddTabCheckable QGroupBoxQStackedWidget is similar to QTabWidgetQResizeEvent.oldSizeisInstancehasattr(button,"text")blockSignalsQframe.NoFramesetSizeConstraint(Qlayout.SetFixedSize)setFrameStyle(Qframe.StyledPanel | Qframe.Sunken)setFrameStyle(Qframe.Vline| Qframe.Sunken)QSplitter(Qt.Vertical)setCentralWidgetrestoreState(settings.value("MainSplitter"),toByteArray())settings.setValue()Qvariant(self.size())Qvariant(self.pos())Qvariant(self.saveState())event.ignore()QsettingsQvariantcloseEventokToContinueQMainWindowsetAttribute(Qt.WA_DeleteOnClose)Window should take care of saving unsaved changes and cleanupcreateAction(menutext, fun, QKeySequence.Close, icon, tooltip)self.menuBar.addMenuQFileDialog.getOpenFileNameQapplication.closeAllWindows()isAliveisModifiedapp.setWindowIcon(Qicon(": icon.png"))import sipsip.unwrapinstance(qobj) @staticMethod @pyqtSignatureactivateWindowraise_()isinstance(object, class)closeEventactivateNextWindowactivatePreviousWindowcascadewindowRestoreAllwindowMinimizeAllQworkspaceQWorkSpace.setScrollBarsEnabledQKeySequence.NextChildQKeySequence.NewQKeySequence.Paste__version__ string for applicationssetFocusPolicy(Qt.NoFocus)Qimage is NOT a QobjectsetupUi call QtCore.QMetaObject.connectSlotsByNameon_widgetname_signalnameMAC = hasattr(PyQt4.QtGui, "qt_mac_set_native_menubar")

QactionsetToolTipsetShortcutsetStatusTipconnect(action,SIGNAL("triggered()"),method)setShortcut("Ctrl+Q")fileMenu.addAction()fileToolBar.addAction()QActionGroup should be given explicit parentgroup.addActionself.menuBar().addMenu(...)

addSeparatormnuobj.addMenu(second_lvl_menu_icon, name)edittoolbar.addWidget(editbox)Qprinterself.statusBar()setSizeGripEnabledaddPermanentWidgetshowMessage(message, dura)clearMessage

QSpinBoxsetRangesetValuesetSuffixsetToolTipsetStatusTipsetFocusPolicysetMinimumSizesetAlignment(Qt.AlignCenter)setContextMenuPolicy(Qt.ActionsContextMenu)setCentralWidgettoolbars can have combo boxes and spin boxes

setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)setObjectName("LogDockWidget")addDockWidget(area,dockobj)QDockWidget(title,parent)For DockWidgets parent is must because they are not put into layoutsetFeatures to control float, move and closable property of Dock WindowsEvery Qobject Subclass except Top level windows has parentParent is set during Laying outBut for pure data objects like Qaction parent should be set explicitlyQapplication.applicationDirPath()os.path.dirname(__file__)pyrcc4 -o qrc_resources.py resources.qrcQMessageBox.question()critical, information, question, warningQMessageBox.YesQMessageBox.NoQMessageBox.Cancelpop up message box by QMessageBox.exec_()QMessageBox.addButton()QMessageBox.setIcon()os.path.basename()QFileInfo.fileName()QDragEnterEventQDragMOveEventQDropEventsetAcceptDropssetDragEnabledevent.accept()event.ignore()event.setDropAction(Qt.CopyACtion)Qdragdrag.setMimedatadrag.setHotSpotdrag.setPixmapdrag.exec_()drap.start()QClipBoardclipboard.setPixMapclipboard.setMimeDataQPixMapQimageQMimeDatamimeData.setHtml()mimeData.hasHtml()mimeData.html()event.mimeData.hasFormat()extra slection clipboardsetViewModeQListWidget.IconModeQListWidgetItemQDataStream

Rplottypemainxlabylabxlimylimcolxaxs,yaxs

ncolcexlty,lwdbty

heightwidthunitslength(sales$City)read.csvbarplotdotchart

seq()1:10c()ls()data()

byrow=TRUE

cbindrbindvectors,lists,matrices,dataframesnumeric,character,logicalbarplotnames.arghorizinstall.packages("maps")library(maps)requireHeat maps are colorful images, which are very useful for summarizing a large amount of data by highlighting hotspots or key trends in the data.

Heat maps are very useful for looking at correlations between variables in a large dataset

histograms and density plots, which are useful to look at the distribution of values in a dataset

box plots, which are useful in comparing the spread of values in different measurements

Bar plots are often used to compare the values of groups of values across categories

barplot(as.matrix(sales[,2:4]), beside=TRUE,legend=sales$City,col=heat.colors(5),border="white").

boxplot(metals,xlab="Metals",ylab="Atmospheric Concentration in ng per cubic metre",main="Atmospheric Metal Concentrations in London")

histrnorm(1000)vector1[c(2, 4, 5)]vector1[-5]matrix1[1:2, 3]dendrogram

mynumbers